Skip to content
Open
Show file tree
Hide file tree
Changes from 11 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
39 changes: 27 additions & 12 deletions Config.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include <cmath>
#include <iostream>
#include <fstream>
#include <string>
Expand Down Expand Up @@ -50,6 +51,20 @@ namespace {
return retVal;
}

int autoSegForXY = autosizer();
int getSegmentSizeConfig(string setting, string line, bool autosize) {
int value = DEFAULT_SEGSIZE_XY;
if (autosize) {
value = autoSegForXY;
} else {
value = parseIntFromLine(setting, line);
value = ((value < MIN_SEGSIZE) ? DEFAULT_SEGSIZE_XY : value);
}
//plus 2 to allow edge readings
value += 2;
return value;
}


void parseConfigLine(string line)
{
Expand Down Expand Up @@ -84,25 +99,25 @@ namespace {
ssConfig.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
ssState.Size.x = value + 2;
ssState.Size.y = value + 2;
bool autosize = (parseStrFromLine("SEGMENTSIZE_XY", line) == "AUTO");
ssState.Size.x = getSegmentSizeConfig("SEGMENTSIZE_XY", line, autosize);
ssState.Size.y = getSegmentSizeConfig("SEGMENTSIZE_XY", line, autosize);
}
if (line.find("[SEGMENTSIZE_X") != string::npos) {
bool autosize = (parseStrFromLine("SEGMENTSIZE_X", line) == "AUTO");
ssState.Size.x = getSegmentSizeConfig("SEGMENTSIZE_X", line, autosize);
}
if (line.find("[SEGMENTSIZE_Y") != string::npos) {
bool autosize = (parseStrFromLine("SEGMENTSIZE_Y", line) == "AUTO");
ssState.Size.y = getSegmentSizeConfig("SEGMENTSIZE_Y", line, autosize);
}
if (line.find("[SEGMENTSIZE_Z") != string::npos) {
int value = parseIntFromLine("SEGMENTSIZE_Z", line);
if (value < 1) {
value = DEFAULT_SIZE_Z;
value = DEFAULT_SEGSIZE_Z;
}
ssState.Size.z = value;
}

if (line.find("[ALLCREATURES") != string::npos) {
string result = parseStrFromLine("ALLCREATURES", line);
ssConfig.show_all_creatures = (result == "YES");
Expand Down
7 changes: 5 additions & 2 deletions common.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,9 @@ constexpr auto SPRITEWIDTH = TILEWIDTH;
constexpr auto SPRITEHEIGHT = (TILETOPHEIGHT + WALLHEIGHT);
constexpr auto WALL_CUTOFF_HEIGHT = 15;

constexpr auto DEFAULT_SIZE = 20;
constexpr auto DEFAULT_SIZE_Z = 6;
constexpr auto MIN_SEGSIZE = 1;
constexpr auto DEFAULT_SEGSIZE_XY = 20;
constexpr auto DEFAULT_SEGSIZE_Z = 6;
constexpr auto MAPNAVIGATIONSTEP = 1;
constexpr auto MAPNAVIGATIONSTEPBIG = 10;

Expand Down Expand Up @@ -257,3 +258,5 @@ constexpr auto FORM_BOULDER = 3;
constexpr auto FORM_LOG = 4;

extern int randomCube[RANDOM_CUBE][RANDOM_CUBE][RANDOM_CUBE];

int autosizer();
2 changes: 2 additions & 0 deletions commonTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,8 @@ class dfColors

struct GameConfiguration {
bool overlay_mode;
bool autosize_segmentX;
bool autosize_segmentY;
bool show_zones;
bool show_stockpiles;
bool show_designations;
Expand Down
6 changes: 4 additions & 2 deletions configs/init.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,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:70]
[SEGMENTSIZE_Y:70]
[SEGMENTSIZE_Z:4]

Change this to off to skip the intro.
Expand Down
3 changes: 2 additions & 1 deletion docs/changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +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 keys for resizing the segmentsize
## Fixes
- `stonesense`: fixed crash when maximizing or resizing the window

Expand Down
22 changes: 18 additions & 4 deletions 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 @@ -237,7 +238,7 @@ void drawcredits()
al_draw_text(font, color_white, centerx, bottomy-12*lineheight, ALLEGRO_ALIGN_CENTRE, "7c Nickel, BatCountry, Belal, Belannaer, DeKaFu, Dante, Deon, dyze,");
al_draw_text(font, color_white, centerx, bottomy-11*lineheight, ALLEGRO_ALIGN_CENTRE, "Errol, fifth angel, frumpton, IDreamOfGiniCoeff, Impaler, ");
al_draw_text(font, color_white, centerx, bottomy-10*lineheight, ALLEGRO_ALIGN_CENTRE, "Japa, jarathor, Jiri Petru, Jordix, Lord Nightmare, McMe, Mike Mayday, Nexii ");
al_draw_text(font, color_white, centerx, bottomy-9*lineheight, ALLEGRO_ALIGN_CENTRE, "Malthus, peterix, Seuss, soup, Talvara, winner, Xandrin.");
al_draw_text(font, color_white, centerx, bottomy-9*lineheight, ALLEGRO_ALIGN_CENTRE, "Malthus, peterix, Seuss, soup, SquidCoder, Talvara, winner, Xandrin.");

al_draw_text(font, color_white, centerx, bottomy-7*lineheight, ALLEGRO_ALIGN_CENTRE, "With special thanks to peterix for making dfHack");

Expand All @@ -246,6 +247,10 @@ void drawcredits()
// Make the backbuffer visible
}

int autosizer() {
return (int)std::ceil(std::sqrt(2) * (ssState.ScreenW + 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 @@ -340,6 +345,13 @@ static void main_loop(ALLEGRO_DISPLAY * display, ALLEGRO_EVENT_QUEUE *queue, ALL
case ALLEGRO_EVENT_DISPLAY_RESIZE:
if (ssConfig.overlay_mode) {
break;

}
if (ssConfig.autosize_segmentX) {
ssState.Size.x = autosizer();
}
if (ssConfig.autosize_segmentY){
ssState.Size.y = autosizer();
}
timeToReloadSegment = true;
redraw = true;
Expand Down Expand Up @@ -400,15 +412,17 @@ static void * stonesense_thread(ALLEGRO_THREAD * main_thread, void * parms)
ssConfig.shade_hidden_tiles = true;
ssConfig.load_ground_materials = true;
ssConfig.automatic_reload_time = 0;
ssConfig.autosize_segmentX = false;
ssConfig.autosize_segmentY = false;
ssConfig.automatic_reload_step = 500;
ssConfig.lift_segment_offscreen_x = 0;
ssConfig.lift_segment_offscreen_y = 0;
ssConfig.Fullscreen = FULLSCREEN;
ssState.ScreenH = RESOLUTION_HEIGHT;
ssState.ScreenW = RESOLUTION_WIDTH;
ssState.Size.x = DEFAULT_SIZE;
ssState.Size.y = DEFAULT_SIZE;
ssState.Size.z = DEFAULT_SIZE_Z;
ssState.Size.x = DEFAULT_SEGSIZE_XY;
ssState.Size.y = DEFAULT_SEGSIZE_XY;
ssState.Size.z = DEFAULT_SEGSIZE_Z;
ssConfig.show_creature_names = false;
ssConfig.show_osd = true;
ssConfig.show_designations = true;
Expand Down
8 changes: 6 additions & 2 deletions resources/keybinds.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,12 @@ KEYBINDINGS:
[CHOP_WALLS:KEY_C]
[CYCLE_TRACKING_MODE:KEY_F]
[RESET_VIEW_OFFSET:KEY_Z]
[DECR_SEGMENT_Z:KEY_1]
[INCR_SEGMENT_Z:KEY_2]
[DECR_SEGMENT_Z:KEYPAD_3]
[INCR_SEGMENT_Z:KEYPAD_9]
[DECR_SEGMENT_X:KEYPAD_4]
[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