Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

To become: Stonesense Docs and Changelog Update #121

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
73f1c25
various config changes
realSquidCoder Dec 26, 2024
0e72c68
add closeOnEsc config internally, off by default.
realSquidCoder Dec 27, 2024
d3529c8
added some logging to check the profession issue.
realSquidCoder Jan 1, 2025
043a552
Merge remote-tracking branch 'origin/master' into squid-config-rewrite
realSquidCoder Jan 3, 2025
c034d83
Cleaned up keybinds and reverted a logging commit
realSquidCoder Jan 8, 2025
c59568c
missed a whitespace. fixing for precommit
realSquidCoder Jan 8, 2025
51feeba
i forgot to put toggleannouncements in the header file.
realSquidCoder Jan 8, 2025
933878a
Ducttape patch the resize crash for now.
realSquidCoder Jan 8, 2025
9ea7e1a
cleaned the fix to only run on windows as its only found on there
realSquidCoder Jan 9, 2025
922faac
preecommit fix and add keybind to hide fog (~ by default)
realSquidCoder Jan 9, 2025
d234c0b
revert all my crash fixes. the fix is using openGL
realSquidCoder Jan 9, 2025
bab420a
FINALLY fix the whitespace issue for precommit
realSquidCoder Jan 9, 2025
15e524f
FIx: closeOnEsc is now actually a config and removed some old un-need…
realSquidCoder Jan 9, 2025
23f4d71
Update the changelogs and docs
realSquidCoder Jan 9, 2025
e8c1586
Announcements are seperately displayed now.
realSquidCoder Jan 9, 2025
44b133d
Added more debug info and added debug keybinds
realSquidCoder Jan 9, 2025
13ef7f6
moved keybinds to be alongside init.txt in dfhack-config
realSquidCoder Jan 9, 2025
e7f04d7
Update the docs to reflect moved keybinds file
realSquidCoder Jan 9, 2025
a28629f
everything is in configs folder, not `/resources/`
realSquidCoder Jan 9, 2025
9c7e3ea
Make zoom increments smaller and put ui scale on the back burner
realSquidCoder Jan 9, 2025
6aae0fb
Removed the (currently) useless uiscale keybinds from the default keys
realSquidCoder Jan 9, 2025
29c8252
Update the changelog and added some info for the switch to OpenGL
realSquidCoder Jan 9, 2025
95bd6d9
added configs to init for showing mood, jobs, and professions
realSquidCoder Jan 9, 2025
38cd00b
Whitespace precommit fixes
realSquidCoder Jan 9, 2025
be986db
added parsing for the new status configs
realSquidCoder Jan 9, 2025
484bcfd
added in segment autosizing from a feature request
realSquidCoder Jan 9, 2025
63e54da
try and fix build fail on linux
realSquidCoder Jan 10, 2025
501171e
add code to change uiscale
realSquidCoder Jan 10, 2025
54cc451
moved splash text around so it looks better
realSquidCoder Jan 10, 2025
7cb4788
fix https://github.com/DFHack/stonesense/issues/13
realSquidCoder Jan 10, 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
47 changes: 39 additions & 8 deletions Config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ void parseConfigLine( string line )
return;
}

if( line.find("[CLOSEONESC") != string::npos) {
string result = parseStrFromLine("CLOSEONESC", line );
ssConfig.closeOnEsc = (result == "YES");
}
if( line.find("[WIDTH") != string::npos) {
int width = parseIntFromLine( "WIDTH", line );
ssState.ScreenW = width;
Expand All @@ -80,17 +84,27 @@ void parseConfigLine( string line )
string result = parseStrFromLine( "WINDOWED", line );
ssConfig.Fullscreen = (result == "NO");
}
if( line.find("[SEGMENTSIZE_XY") != string::npos) {
int value = parseIntFromLine( "SEGMENTSIZE_XY", line );
if(value < 1) {
if (line.find("[SEGMENTSIZE_X") != string::npos) {
int value = parseIntFromLine("SEGMENTSIZE_X", line);
if (value < 1) {
value = DEFAULT_SIZE;
}
if(value > 100) {
if (value > 100) {
value = 100;
}
//plus 2 to allow edge readings
ssState.Size.x = value+2;
ssState.Size.y = value+2;
ssState.Size.x = value + 2;
}
if (line.find("[SEGMENTSIZE_Y") != string::npos) {
int value = parseIntFromLine("SEGMENTSIZE_Y", line);
if (value < 1) {
value = DEFAULT_SIZE;
}
if (value > 100) {
value = 100;
}
//plus 2 to allow edge readings
ssState.Size.y = value + 2;
}
if( line.find("[SEGMENTSIZE_Z") != string::npos) {
int value = parseIntFromLine( "SEGMENTSIZE_Z", line );
Expand All @@ -100,6 +114,11 @@ void parseConfigLine( string line )
ssState.Size.z = value;
}

if (line.find("[AUTOSIZE_SEGMENT") != string::npos) {
string result = parseStrFromLine("AUTOSIZE_SEGMENT", line);
ssConfig.autosize_segment = (result == "YES");
}

if( line.find("[ALLCREATURES") != string::npos) {
string result = parseStrFromLine( "ALLCREATURES", line );
ssConfig.show_all_creatures = (result == "YES");
Expand Down Expand Up @@ -159,10 +178,22 @@ void parseConfigLine( string line )
string result = parseStrFromLine( "FOLLOW_DF_CURSOR", line );
ssConfig.follow_DFcursor = (result == "YES");
}
if( line.find("[SHOW_CREATURE_NAMES") != string::npos) {
string result = parseStrFromLine( "SHOW_CREATURE_NAMES", line );
if (line.find("[SHOW_CREATURE_NAMES") != string::npos) {
string result = parseStrFromLine("SHOW_CREATURE_NAMES", line);
ssConfig.show_creature_names = (result == "YES");
}
if (line.find("[SHOW_CREATURE_MOODS") != string::npos) {
string result = parseStrFromLine("SHOW_CREATURE_MOODS", line);
ssConfig.show_creature_moods = (result == "YES");
}
if (line.find("[SHOW_CREATURE_JOBS") != string::npos) {
string result = parseStrFromLine("SHOW_CREATURE_JOBS", line);
ssConfig.show_creature_jobs = (result == "YES");
}
if (line.find("[SHOW_CREATURE_PROFESSIONS") != string::npos) {
int value = parseIntFromLine("SHOW_CREATURE_PROFESSIONS", line);
ssConfig.show_creature_professions = value;
}
if( line.find("[NAMES_USE_NICKNAME") != string::npos) {
string result = parseStrFromLine( "NAMES_USE_NICKNAME", line );
ssConfig.names_use_nick = (result == "YES");
Expand Down
9 changes: 5 additions & 4 deletions Creatures.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -410,14 +410,15 @@ void DrawCreatureText(int drawx, int drawy, SS_Unit* creature )
textcol = al_map_rgb(255,255,255);
}

if (!creature->origin->name.nickname.empty() && ssConfig.names_use_nick) {
auto name = Units::getVisibleName(creature->origin);
if (!name->nickname.empty() && ssConfig.names_use_nick) {
draw_textf_border(font, textcol, drawx, drawy-((WALLHEIGHT*ssConfig.scale)+al_get_font_line_height(font) + offsety), 0,
"%s", DF2UTF(creature->origin->name.nickname).c_str());
"%s", DF2UTF(name->nickname).c_str());
}
else if (!creature->origin->name.first_name.empty())
else if (!name->first_name.empty())
{
char buffer[128];
strncpy(buffer,creature->origin->name.first_name.c_str(),127);
strncpy(buffer,name->first_name.c_str(), 127);
buffer[127]=0;
ALLEGRO_USTR* temp = bufferToUstr(buffer, 128);
al_ustr_set_chr(temp, 0, charToUpper(al_ustr_get(temp, 0)));
Expand Down
24 changes: 15 additions & 9 deletions GUI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1159,6 +1159,11 @@ void paintboard()
ssTimers.frame_total = (donetime - ssTimers.prev_frame_time)*0.1 + ssTimers.frame_total*0.9;
ssTimers.prev_frame_time = donetime;

if(ssConfig.show_announcements) {
al_hold_bitmap_drawing(true);
draw_announcements(font, ssState.ScreenW, ssState.ScreenH - 20, ALLEGRO_ALIGN_RIGHT, df::global::world->status.announcements);
al_hold_bitmap_drawing(false);
}
if(ssConfig.show_keybinds){
string *keyname, *actionname;
keyname = actionname = NULL;
Expand All @@ -1182,18 +1187,19 @@ void paintboard()

drawDebugCursor(segment);

draw_announcements(font, ssState.ScreenW, ssState.ScreenH - 20, ALLEGRO_ALIGN_RIGHT, df::global::world->status.announcements);
drawAdvmodeMenuTalk(font, 5, ssState.ScreenH - 5);

if(ssConfig.debug_mode) {
draw_textf_border(font, uiColor(1), 10, 3*al_get_font_line_height(font), 0, "Map Read Time: %.2fms", ssTimers.read_time);
draw_textf_border(font, uiColor(1), 10, 4*al_get_font_line_height(font), 0, "Map Beautification Time: %.2fms", ssTimers.beautify_time);
draw_textf_border(font, uiColor(1), 10, 5*al_get_font_line_height(font), 0, "Tile Sprite Assembly Time: %.2fms", ssTimers.assembly_time);
draw_textf_border(font, uiColor(1), 10, 6*al_get_font_line_height(font), 0, "DF Renderer Overlay Time: %.2fms", ssTimers.overlay_time);
draw_textf_border(font, uiColor(1), 10, 2*al_get_font_line_height(font), 0, "FPS: %.2f", 1000.0/ssTimers.frame_total);
draw_textf_border(font, uiColor(1), 10, 7*al_get_font_line_height(font), 0, "Draw: %.2fms", ssTimers.draw_time);
draw_textf_border(font, uiColor(1), 10, 8*al_get_font_line_height(font), 0, "D1: %i", DebugInt1);
draw_textf_border(font, uiColor(1), 10, 9*al_get_font_line_height(font), 0, "%i/%i/%i, %i:%i", contentLoader->currentDay+1, contentLoader->currentMonth+1, contentLoader->currentYear, contentLoader->currentHour, (contentLoader->currentTickRel*60)/50);
draw_textf_border(font, uiColor(1), 10, 2*al_get_font_line_height(font), 0, "Zoom: %.2f", ssConfig.zoom);
draw_textf_border(font, uiColor(1), 10, 3*al_get_font_line_height(font), 0, "Scale: %.8f", ssConfig.scale);
draw_textf_border(font, uiColor(1), 10, 4*al_get_font_line_height(font), 0, "FPS: %.2f", 1000.0/ssTimers.frame_total);
draw_textf_border(font, uiColor(1), 10, 5*al_get_font_line_height(font), 0, "Map Read Time: %.2fms", ssTimers.read_time);
draw_textf_border(font, uiColor(1), 10, 6*al_get_font_line_height(font), 0, "Map Beautification Time: %.2fms", ssTimers.beautify_time);
draw_textf_border(font, uiColor(1), 10, 7*al_get_font_line_height(font), 0, "Tile Sprite Assembly Time: %.2fms", ssTimers.assembly_time);
draw_textf_border(font, uiColor(1), 10, 8*al_get_font_line_height(font), 0, "DF Renderer Overlay Time: %.2fms", ssTimers.overlay_time);
draw_textf_border(font, uiColor(1), 10, 9*al_get_font_line_height(font), 0, "Draw: %.2fms", ssTimers.draw_time);
draw_textf_border(font, uiColor(1), 10, 10*al_get_font_line_height(font), 0, "D1: %i", DebugInt1);
draw_textf_border(font, uiColor(1), 10, 11*al_get_font_line_height(font), 0, "%i/%i/%i, %i:%i", contentLoader->currentDay+1, contentLoader->currentMonth+1, contentLoader->currentYear, contentLoader->currentHour, (contentLoader->currentTickRel*60)/50);

drawDebugInfo(segment);
}
Expand Down
8 changes: 7 additions & 1 deletion Keybinds.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ action_name_mapper actionnamemap[] = {
{"TOGGLE_STOCKS", action_togglestockpiles},
{"TOGGLE_ZONES", action_togglezones},
{"TOGGLE_OCCLUSION", action_toggleocclusion},
{"TOGGLE_FOG",action_togglefog},
{"TOGGLE_CREATURE_MOODS", action_togglecreaturemood},
{"TOGGLE_CREATURE_PROFS", action_togglecreatureprof},
{"TOGGLE_CREATURE_JOBS", action_togglecreaturejob},
Expand All @@ -198,8 +199,12 @@ action_name_mapper actionnamemap[] = {
{"TOGGLE_SHOW_HIDDEN_TILES", action_toggleshowhidden},
{"TOGGLE_OSD", action_toggleosd},
{"TOGGLE_KEYBINDS", action_togglekeybinds},
{"TOGGLE_ANNOUNCEMENTS", action_toggleannouncements},
{"TOGGLE_DEBUG", action_toggledebug},
{"INCR_ZOOM", action_incrzoom},
{"DECR_ZOOM", action_decrzoom},
{"INCR_UISCALE", action_incruiscale},
{"DECR_UISCALE", action_decruiscale},
{"SCREENSHOT", action_screenshot},
{"INCR_RELOAD_TIME", action_incrreloadtime},
{"DECR_RELOAD_TIME", action_decrreloadtime},
Expand All @@ -219,6 +224,7 @@ action_name_mapper actionnamemap[] = {
{"INCR_Y", action_incrY},
{"DECR_X", action_decrX},
{"INCR_X", action_incrX},

//add extra action here!

{"INVALID", action_invalid}//this is the stop condition
Expand Down Expand Up @@ -273,7 +279,7 @@ void parseKeymapLine( string line )

bool loadKeymapFile(){
string line;
ALLEGRO_PATH * p =al_create_path("stonesense/keybinds.txt");
ALLEGRO_PATH * p =al_create_path("dfhack-config/stonesense/keybinds.txt");
const char * path = al_path_cstr(p,ALLEGRO_NATIVE_PATH_SEP);
ifstream myfile (path);
if (myfile.is_open() == false) {
Expand Down
35 changes: 34 additions & 1 deletion UserInput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,11 @@ void action_toggleocclusion(uint32_t keymod)
timeToReloadSegment = true;
}

void action_togglefog(uint32_t keymod)
{
ssConfig.fogenable= !ssConfig.fogenable;
}

void action_togglecreaturemood(uint32_t keymod)
{
ssConfig.show_creature_moods = !ssConfig.show_creature_moods;
Expand Down Expand Up @@ -382,16 +387,44 @@ void action_togglekeybinds(uint32_t keymod){
ssConfig.show_keybinds = !ssConfig.show_keybinds;
}

void action_toggleannouncements(uint32_t keymod) {
ssConfig.show_announcements = !ssConfig.show_announcements;
}

void action_toggledebug(uint32_t keymod)
{
ssConfig.debug_mode = !ssConfig.debug_mode;
}

void action_incrzoom(uint32_t keymod)
{
ssConfig.zoom++;
ssConfig.scale = pow(2.0f, ssConfig.zoom);
if (ssConfig.scale <= 1) {
ssConfig.scale = pow(2.0f, ssConfig.zoom);
}
else {
ssConfig.scale++;
}
}

void action_decrzoom(uint32_t keymod)
{
ssConfig.zoom--;
if (ssConfig.scale <= 1) {
ssConfig.scale = pow(2.0f, ssConfig.zoom);
} else {;
ssConfig.scale--;
}
}

void action_incruiscale(uint32_t keymod)
{
ssConfig.fontsize++;
}

void action_decruiscale(uint32_t keymod)
{
ssConfig.fontsize--;
}

void action_screenshot(uint32_t keymod)
Expand Down
5 changes: 5 additions & 0 deletions UserInput.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ void action_toggledesignations(uint32_t keymod);
void action_togglestockpiles(uint32_t keymod);
void action_togglezones(uint32_t keymod);
void action_toggleocclusion(uint32_t keymod);
void action_togglefog(uint32_t keymod);
void action_togglecreaturemood(uint32_t keymod);
void action_togglecreatureprof(uint32_t keymod);
void action_togglecreaturejob(uint32_t keymod);
Expand All @@ -24,9 +25,13 @@ void action_toggleshadehidden(uint32_t keymod);
void action_toggleshowhidden(uint32_t keymod);
void action_togglecreaturenames(uint32_t keymod);
void action_toggleosd(uint32_t keymod);
void action_toggledebug(uint32_t keymod);
void action_togglekeybinds(uint32_t keymod);
void action_toggleannouncements(uint32_t keymod);
void action_incrzoom(uint32_t keymod);
void action_decrzoom(uint32_t keymod);
void action_incruiscale(uint32_t keymod);
void action_decruiscale(uint32_t keymod);
void action_screenshot(uint32_t keymod);
void action_incrreloadtime(uint32_t keymod);
void action_decrreloadtime(uint32_t keymod);
Expand Down
3 changes: 3 additions & 0 deletions commonTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -141,11 +141,14 @@ class dfColors

struct GameConfiguration {
bool overlay_mode;
bool autosize_segment;
bool show_zones;
bool show_stockpiles;
bool show_designations;
bool show_osd;
bool show_announcements;
bool show_keybinds;
bool closeOnEsc;
bool single_layer_view;
bool shade_hidden_tiles;
bool show_hidden_tiles;
Expand Down
23 changes: 18 additions & 5 deletions configs/init.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ Please note, these keywords are case sensitive for now.

--Interface--

Sets whether hitting Esc will close the window. (YES or NO)
[CLOSEONESC:NO]

Sets the width and height of the application in pixels.
[WIDTH:800]
[HEIGHT:600]
Expand All @@ -12,11 +15,15 @@ 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:70]
[SEGMENTSIZE_Y:70]
[SEGMENTSIZE_Z:4]

Dynamically set SEGMENTSIZE when the window is resized.
[AUTOSIZE_SEGMENT:NO]

Change this to off to skip the intro.
[INTRO:OFF]

Expand Down Expand Up @@ -92,8 +99,13 @@ Sets Stonesense in debug mode. Adds additional information to displays.
Sets the debug cursor to follow the cursor from DF when it is there.
[FOLLOW_DF_CURSOR:YES]

Shows creatures names floating above their sprites. (Toggle with 'n')
[SHOW_CREATURE_NAMES:YES]
Shows creatures info floating above their sprites.
[SHOW_CREATURE_NAMES:NO]
[SHOW_CREATURE_MOODS:NO]
[SHOW_CREATURE_JOBS:NO]

Show creatures professions. (0-3, 0 is off)
[SHOW_CREATURE_PROFESSIONS:0]

Options to control how names are displayed (if SHOW_CREATURE_NAMES is set)
[NAMES_USE_NICKNAME:YES]
Expand Down Expand Up @@ -131,7 +143,8 @@ and possibly quickly fill up yout hard-drive.

Set the preferred renderer. Valid values are SOFTWARE, OPENGL, DIRECTX, and ANY. SOFTWARE has the highest
compatibility, but is very slow.
[RENDERER:ANY]
On Windows, you should leave this on OPENGL for stability reasons.
[RENDERER:OPENGL]

--Colors--

Expand Down
Loading
Loading