Skip to content

Commit cbb952b

Browse files
committed
Merge remote-tracking branch 'upstream/master' into v51.05
2 parents 3cf5586 + 83ff842 commit cbb952b

File tree

15 files changed

+1041
-171
lines changed

15 files changed

+1041
-171
lines changed

.github/workflows/generate-symbols.yml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -163,8 +163,9 @@ jobs:
163163
pip install itch-dl
164164
minor=$(echo "${{ inputs.version }}" | cut -d. -f1)
165165
patch=$(echo "${{ inputs.version }}" | cut -d. -f2)
166-
itch-dl https://kitfoxgames.itch.io/dwarf-fortress --download-to . --api-key $ITCH_API_KEY
167-
tar xjf "kitfoxgames/dwarf-fortress/files/dwarf_fortress_${minor}_${patch}_linux.tar.bz2" -C DF_itch
166+
fname="dwarf_fortress_${minor}_${patch}_linux.tar.bz2"
167+
itch-dl https://kitfoxgames.itch.io/dwarf-fortress --download-to . --api-key $ITCH_API_KEY --filter-files-glob "${fname}"
168+
tar xjf "kitfoxgames/dwarf-fortress/files/${fname}" -C DF_itch
168169
tar xjf dfhack-symbols-linux64-build.tar.bz2 -C DF_itch
169170
xml/symbols_gen_linux.sh ${{ inputs.version }} ITCH DF_itch
170171
@@ -270,8 +271,9 @@ jobs:
270271
pip install itch-dl
271272
minor=$(echo "${{ inputs.version }}" | cut -d. -f1)
272273
patch=$(echo "${{ inputs.version }}" | cut -d. -f2)
273-
itch-dl https://kitfoxgames.itch.io/dwarf-fortress --download-to . --api-key $ITCH_API_KEY
274-
unzip -d DF_itch "kitfoxgames/dwarf-fortress/files/dwarf_fortress_${minor}_${patch}_windows.zip"
274+
fname="dwarf_fortress_${minor}_${patch}_windows.zip"
275+
itch-dl https://kitfoxgames.itch.io/dwarf-fortress --download-to . --api-key $ITCH_API_KEY --filter-files-glob "${fname}"
276+
unzip -d DF_itch "kitfoxgames/dwarf-fortress/files/${fname}"
275277
xml/symbols_gen_windows.sh ${{ inputs.version }} ITCH DF_itch
276278
277279
# Classic

.github/workflows/watch-df-release.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,8 @@ jobs:
117117
- name: Compare versions
118118
uses: nick-fields/retry@v3
119119
with:
120-
timeout_minutes: 2
120+
timeout_minutes: 5
121+
retry_wait_seconds: 60
121122
command: |
122123
version=$(wget "${{ matrix.url }}" -qO- | tr '"' '\n' | fgrep 'tar.bz2' | head -n1 | sed -r 's/${{ matrix.prefix }}_([0-9]{2})_([0-9]{2})_linux.tar.bz2/\1.\2/')
123124
echo "latest ${{ matrix.channel }} version: $version"

docs/changelog.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,15 @@ Template for new versions:
7272

7373
## Misc Improvements
7474
- Compatibility with DF 51.05
75+
# 51.04-r1.1
76+
77+
## Fixes
78+
- `gui/launcher`: ensure commandline is fully visible when searching through history and switching from a very long command to a short command
79+
- `gui/launcher`: flatten text when pasting multi-line text from the clipboard
80+
- Ctrl-a hotkeys have been changed to something else (Ctrl-n) for tools that also have an editable text field, where Ctrl-a is interpreted as select all text
81+
82+
## API
83+
- ``Core::getUnpausedMs``: new API for getting unpaused ms since load in a fort-mode game
7584

7685
# 51.04-r1
7786

library/Core.cpp

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -145,20 +145,20 @@ bool PerfCounters::getIgnorePauseState() {
145145
return ignore_pause_state;
146146
}
147147

148-
void PerfCounters::registerTick(uint32_t baseline_ms) {
148+
uint32_t PerfCounters::registerTick(uint32_t baseline_ms) {
149149
if (!World::isFortressMode() || World::ReadPauseState()) {
150150
last_tick_baseline_ms = 0;
151-
return;
151+
return 0;
152152
}
153153

154154
// only update when the tick counter has advanced
155155
if (!world || last_frame_counter == world->frame_counter)
156-
return;
156+
return 0;
157157
last_frame_counter = world->frame_counter;
158158

159159
if (last_tick_baseline_ms == 0) {
160160
last_tick_baseline_ms = baseline_ms;
161-
return;
161+
return 0;
162162
}
163163

164164
uint32_t elapsed_ms = baseline_ms - last_tick_baseline_ms;
@@ -173,6 +173,8 @@ void PerfCounters::registerTick(uint32_t baseline_ms) {
173173

174174
recent_ticks.history[recent_ticks.head_idx] = elapsed_ms;
175175
recent_ticks.sum_ms += elapsed_ms;
176+
177+
return elapsed_ms;
176178
}
177179

178180
uint32_t PerfCounters::getUnpausedFps() {
@@ -1705,6 +1707,7 @@ bool Core::InitMainThread() {
17051707
}
17061708

17071709
perf_counters.reset();
1710+
unpaused_ms = 0;
17081711

17091712
return true;
17101713
}
@@ -2141,7 +2144,7 @@ int Core::Update()
21412144
}
21422145

21432146
uint32_t start_ms = p->getTickCount();
2144-
perf_counters.registerTick(start_ms);
2147+
unpaused_ms += perf_counters.registerTick(start_ms);
21452148
doUpdate(out);
21462149
perf_counters.incCounter(perf_counters.total_update_ms, start_ms);
21472150
}
@@ -2337,6 +2340,7 @@ void Core::onStateChange(color_ostream &out, state_change_event event)
23372340
case SC_WORLD_LOADED:
23382341
{
23392342
perf_counters.reset();
2343+
unpaused_ms = 0;
23402344
Persistence::Internal::load(out);
23412345
plug_mgr->doLoadWorldData(out);
23422346
loadModScriptPaths(out);

library/include/Core.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,11 @@ namespace DFHack
100100
bool getIgnorePauseState();
101101

102102
// noop if game is paused and getIgnorePauseState() returns false
103-
void incCounter(uint32_t &perf_counter, uint32_t baseline_ms);
103+
void incCounter(uint32_t &counter, uint32_t baseline_ms);
104+
105+
// returns number of unpaused ms since last tick
106+
uint32_t registerTick(uint32_t baseline_ms);
104107

105-
void registerTick(uint32_t baseline_ms);
106108
uint32_t getUnpausedFps();
107109

108110
private:
@@ -219,6 +221,7 @@ namespace DFHack
219221
static void cheap_tokenise(std::string const& input, std::vector<std::string> &output);
220222

221223
PerfCounters perf_counters;
224+
uint32_t getUnpausedMs() { return unpaused_ms; }
222225

223226
lua_State* getLuaState(bool bypass_assertion = false) {
224227
assert(bypass_assertion || isSuspended());
@@ -334,6 +337,8 @@ namespace DFHack
334337

335338
lua_State* State;
336339

340+
uint32_t unpaused_ms; // reset to 0 on map load
341+
337342
friend class CoreService;
338343
friend class ServerConnection;
339344
friend class CoreSuspender;

library/lua/gui/widgets/edit_field.lua

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,6 @@ function EditField:init()
114114
self:setFocus(true)
115115
end
116116

117-
self.start_pos = 1
118117
self.cursor = #self.text + 1
119118
self.ignore_keys = self.ignore_keys or {}
120119

library/lua/gui/widgets/text_area.lua

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,15 @@ function TextArea:setText(text)
6969
self:getCursor()
7070
)
7171

72-
return self.text_area:setText(text)
72+
self.text_area:setText(text)
73+
74+
if self.one_line_mode then
75+
self.render_start_x = 1
76+
local cursor = self:getCursor()
77+
if cursor then
78+
self:setCursor(math.min(self:getCursor(), #text + 1))
79+
end
80+
end
7381
end
7482

7583
function TextArea:getCursor()

library/lua/gui/widgets/text_area/text_area_content.lua

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,11 @@ function TextAreaContent:eraseSelection()
127127
end
128128

129129
function TextAreaContent:setClipboard(text)
130-
dfhack.internal.setClipboardTextCp437Multiline(text)
130+
if self.one_line_mode then
131+
dfhack.internal.setClipboardTextCp437(text)
132+
else
133+
dfhack.internal.setClipboardTextCp437Multiline(text)
134+
end
131135
end
132136

133137
function TextAreaContent:copy()
@@ -151,7 +155,7 @@ function TextAreaContent:copy()
151155
self:lineStartOffset(),
152156
self:lineEndOffset()
153157
)
154-
if curr_line:sub(-1,-1) ~= NEWLINE then
158+
if not self.one_line_mode and curr_line:sub(-1,-1) ~= NEWLINE then
155159
curr_line = curr_line .. NEWLINE
156160
end
157161

@@ -170,8 +174,9 @@ function TextAreaContent:cut()
170174
end
171175

172176
function TextAreaContent:paste()
173-
local clipboard_lines = dfhack.internal.getClipboardTextCp437Multiline()
174-
local clipboard = table.concat(clipboard_lines, '\n')
177+
local clipboard = self.one_line_mode and
178+
dfhack.internal.getClipboardTextCp437() or
179+
table.concat(dfhack.internal.getClipboardTextCp437Multiline(), '\n')
175180
if clipboard then
176181
if self.clipboard_mode == CLIPBOARD_MODE.LINE and not self:hasSelection() then
177182
local origin_offset = self.cursor

library/lua/json.lua

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
local _ENV = mkmodule('json')
2-
local internal = require 'json.internal'
2+
3+
local internal = require('json.internal')
34
local fs = dfhack.filesystem
45

56
encode_defaults = {
@@ -39,7 +40,7 @@ function decode_file(path, ...)
3940
end
4041
local contents = f:read('*all')
4142
f:close()
42-
return decode(contents, ...)
43+
return decode(contents, ...) or {}
4344
end
4445

4546
local _file = defclass()

0 commit comments

Comments
 (0)