Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
b3aa1e5
Split SEGMENTSIZE_XY and add an autosize conifg
realSquidCoder Jan 13, 2025
6c8bdcc
Merge branch 'DFHack:master' into squid-segmentsize-changes
realSquidCoder Jan 15, 2025
166e8c8
change how we do autosizing
realSquidCoder Jan 15, 2025
8914fae
forgot cmath and the renaming of vars
realSquidCoder Jan 15, 2025
2e49f32
Merge branch 'DFHack:master' into squid-segmentsize-changes
realSquidCoder Jan 15, 2025
0f3a8e0
remove use of std::min
realSquidCoder Jan 15, 2025
59b0f47
Resolve code review things and add keybinds
realSquidCoder Jan 15, 2025
234a2fd
cleaned autosizer
realSquidCoder Jan 16, 2025
5904d00
Update changelog.txt
realSquidCoder Jan 16, 2025
f0c0520
Forgot cmath
realSquidCoder Jan 16, 2025
c23aa74
fixing up autosizer
realSquidCoder Jan 16, 2025
5291b38
Code review changes
realSquidCoder Jan 16, 2025
260a255
Revert keys and add my name
realSquidCoder Jan 16, 2025
ed6d416
Fix typo in keys
realSquidCoder Jan 16, 2025
7ad9b31
cleaned up use of getAutoSegmentSize
realSquidCoder Jan 16, 2025
7d3e3b9
Update docs/changelog.txt
realSquidCoder Jan 16, 2025
eeb3305
remove my name. (belongs in a new PR with Rome added too!)
realSquidCoder Jan 16, 2025
e74be9f
Apply suggestions from code review
realSquidCoder Jan 17, 2025
833708c
Merge branch 'DFHack:master' into squid-segmentsize-changes
realSquidCoder Jan 19, 2025
949ac83
Merge files
realSquidCoder Jan 19, 2025
135e2d8
Merge remote-tracking branch 'upstream/master' into squid-segmentsize…
realSquidCoder Jan 19, 2025
ce4ff34
missed a few lines
realSquidCoder Jan 19, 2025
1a88f44
Merge
realSquidCoder Jan 20, 2025
e5c4ca5
Merge branch 'master' into squid-segmentsize-changes
realSquidCoder Jan 21, 2025
1aceaaa
Merge branch 'master' into squid-segmentsize-changes
realSquidCoder Jan 21, 2025
ab3fb1f
Merge branch 'master' into squid-segmentsize-changes
realSquidCoder Jan 23, 2025
f5b81e3
Remember to do an initial resize.
realSquidCoder Jan 25, 2025
1dd470e
Merge branch 'master' into squid-segmentsize-changes
realSquidCoder Jan 25, 2025
07b545f
Use auto bc we made it for a reason
realSquidCoder Feb 13, 2025
4b9957a
Merge branch 'master' into squid-segmentsize-changes
realSquidCoder Feb 13, 2025
8456049
Merge branch 'master' into squid-segmentsize-changes
myk002 Feb 22, 2025
571d3dd
Merge remote-tracking branch 'upstream/master' into squid-segmentsize…
realSquidCoder Mar 6, 2025
1d96ef9
Merge branch 'master' into squid-segmentsize-changes
myk002 Mar 9, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 30 additions & 11 deletions Config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,26 @@ std::optional<std::string> trim_line(std::string line)
return std::optional{ line };
}

int getSegmentSizeConfig(string setting, string line) {
bool autosize = (parseStrFromLine(setting, line) == "AUTO");
int value = DEFAULT_SEGSIZE_XY;
if (autosize) {
value = 1; // will get overwritten when the window comes up
if (setting.ends_with("XY") || setting.ends_with("X")) {
stonesenseState.ssConfig.autosize_segmentX = true;
}
if (setting.ends_with("Y")) {
stonesenseState.ssConfig.autosize_segmentY = true;
}
} else {
value = parseIntFromLine(setting, line);
value = ((value < MIN_SEGSIZE) ? DEFAULT_SEGSIZE_XY : value);
}
//plus 2 to allow edge readings
value += 2;
return value;
}

namespace {
void parseConfigLine(Config& config, string line)
{
Expand All @@ -81,21 +101,20 @@ namespace {
config.Fullscreen = (result == "NO");
}
if (line.find("[SEGMENTSIZE_XY") != string::npos) {
int value = parseIntFromLine("SEGMENTSIZE_XY", line);
if (value < 1) {
value = DEFAULT_SIZE;
}
if (value > 100) {
value = 100;
}
//plus 2 to allow edge readings
config.defaultSegmentSize.x = value;
config.defaultSegmentSize.y = value;
config.defaultSegmentSize.x = getSegmentSizeConfig("SEGMENTSIZE_XY", line);
config.defaultSegmentSize.y = config.defaultSegmentSize.x;
}
if (line.find("[SEGMENTSIZE_X") != string::npos) {
config.defaultSegmentSize.x = getSegmentSizeConfig("SEGMENTSIZE_X", line);
}
if (line.find("[SEGMENTSIZE_Y") != string::npos) {
config.defaultSegmentSize.y = getSegmentSizeConfig("SEGMENTSIZE_Y", line);

}
if (line.find("[SEGMENTSIZE_Z") != string::npos) {
int value = parseIntFromLine("SEGMENTSIZE_Z", line);
if (value < 1) {
value = DEFAULT_SIZE_Z;
value = DEFAULT_SEGSIZE_Z;
}
config.defaultSegmentSize.z = value;
}
Expand Down
6 changes: 6 additions & 0 deletions GameConfiguration.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ struct GameConfiguration {
bool show_hidden_tiles = false;
bool load_ground_materials = false;
bool hide_outer_tiles = false;
bool debug_mode = false;
bool autosize_segmentX = false;
bool autosize_segmentY = false;
int lift_segment_offscreen_x = 0;
int lift_segment_offscreen_y = 0;

uint8_t truncate_walls;
bool track_screen_center = true;

Expand Down
3 changes: 3 additions & 0 deletions common.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@ constexpr auto SPRITEWIDTH = TILEWIDTH;
constexpr auto SPRITEHEIGHT = (TILETOPHEIGHT + WALLHEIGHT);
constexpr auto WALL_CUTOFF_HEIGHT = 15;

constexpr auto MIN_SEGSIZE = 1;
constexpr auto DEFAULT_SEGSIZE_XY = 70;
constexpr auto DEFAULT_SEGSIZE_Z = 6;
constexpr auto MAPNAVIGATIONSTEP = 1;
constexpr auto MAPNAVIGATIONSTEPBIG = 10;

Expand Down
6 changes: 4 additions & 2 deletions configs/init.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@ using WIDTH and HEIGHT for resolution. Try and use resolutions compatible
with your drivers, or the program will still load in window mode.
[WINDOWED:YES]

These two options set how large the cube loaded from Dwarf Fortress is.
These three options set how large the cube loaded from Dwarf Fortress is.
Each entry expects the number of tiles to load.
[SEGMENTSIZE_XY:70]
SEGMENTSIZE_X and SEGMENTSIZE_Y allow using "AUTO" (for example "[SEGMENTSIZE_X:AUTO]").
[SEGMENTSIZE_X:AUTO]
[SEGMENTSIZE_Y:AUTO]
[SEGMENTSIZE_Z:4]

Change this to off to skip the intro.
Expand Down
4 changes: 4 additions & 0 deletions configs/keybinds.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ KEYBINDINGS:
[RESET_VIEW_OFFSET:KEY_Z]
[DECR_SEGMENT_Z:KEY_1]
[INCR_SEGMENT_Z:KEY_2]
[DECR_SEGMENT_X:KEYPAD_4]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wherever this keybinding is handled, it's allowing the value to go negative. Same for DECR_SEGMENT_Y

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but it... shouldn't?
image

[INCR_SEGMENT_X:KEYPAD_6]
[DECR_SEGMENT_Y:KEYPAD_2]
[INCR_SEGMENT_Y:KEYPAD_8]
[TOGGLE_SINGLE_LAYER:KEY_S]
[TOGGLE_SHADE_HIDDEN_TILES:KEY_B]
[TOGGLE_SHOW_HIDDEN_TILES:KEY_H]
Expand Down
2 changes: 2 additions & 0 deletions docs/changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ Template for new versions:
# Future

## New Features
- `stonesense`: added ``AUTO`` as an option for the now-split ``SEGMENTSIZE_X`` and ``SEGMENTSIZE_Y``
- `stonesense`: added new hotkeys for resizing the segmentsize
- `stonesense`: stonesense now offsets the view when you are following a unit in DF, to better center the camera on the unit in stonesense

## Fixes
Expand Down
19 changes: 18 additions & 1 deletion main.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include <assert.h>
#include <cmath>
#include <vector>
#include <list>

Expand Down Expand Up @@ -208,6 +209,10 @@ void drawcredits()
// Make the backbuffer visible
}

int getAutoSegmentSize() {
return (int)std::ceil(std::sqrt(2) * (stonesenseState.ssState.ScreenW + stonesenseState.ssState.ScreenH) / TILEWIDTH);
}

/* main_loop:
* The main loop of the program. Here we wait for events to come in from
* any one of the event sources and react to each one accordingly. While
Expand Down Expand Up @@ -306,6 +311,12 @@ static void main_loop(ALLEGRO_DISPLAY * display, ALLEGRO_EVENT_QUEUE *queue, ALL
if (ssConfig.overlay_mode) {
break;
}
if (ssConfig.autosize_segmentX) {
stonesenseState.ssState.Size.x = getAutoSegmentSize();
}
if (ssConfig.autosize_segmentY){
stonesenseState.ssState.Size.y = getAutoSegmentSize();
}
stonesenseState.timeToReloadSegment = true;
redraw = true;
stonesenseState.ssState.ScreenH = event.display.height;
Expand Down Expand Up @@ -368,7 +379,7 @@ static void* stonesense_thread(ALLEGRO_THREAD* main_thread, void* parms)

stonesenseState.ssState.ScreenH = stonesenseState.ssConfig.config.defaultScreenHeight;
stonesenseState.ssState.ScreenW = stonesenseState.ssConfig.config.defaultScreenWidth;
stonesenseState.ssState.Size = { DEFAULT_SIZE, DEFAULT_SIZE, DEFAULT_SIZE_Z };
stonesenseState.ssState.Size = { DEFAULT_SEGSIZE_XY, DEFAULT_SEGSIZE_XY, DEFAULT_SEGSIZE_Z };
stonesenseState.timeToReloadConfig = true;
stonesenseState.contentLoader = std::make_unique<ContentLoader>();

Expand Down Expand Up @@ -496,6 +507,12 @@ static void* stonesense_thread(ALLEGRO_THREAD* main_thread, void* parms)
// init map segment wrapper and its lock, start the reload thread.
initAutoReload();

if (ssConfig.autosize_segmentX) {
stonesenseState.ssState.Size.x = getAutoSegmentSize();
}
if (ssConfig.autosize_segmentY) {
stonesenseState.ssState.Size.y = getAutoSegmentSize();
}
stonesenseState.timeToReloadSegment = false;
// enter event loop here:
main_loop(display, queue, main_thread, out);
Expand Down