Skip to content

Commit

Permalink
add/update default values for GameConfiguration
Browse files Browse the repository at this point in the history
derived from the settings in the standard `init.txt`
  • Loading branch information
ab9rf committed Jan 20, 2025
1 parent 42e7324 commit 545f986
Show file tree
Hide file tree
Showing 7 changed files with 59 additions and 58 deletions.
18 changes: 8 additions & 10 deletions Config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ namespace {
if (value < -30) {
value = -30;
}
ssConfig.viewXoffset = value;
ssConfig.viewOffset.x = value;
}
if (line.find("[FOLLOW_OFFSET_Y") != string::npos) {
int value = parseIntFromLine("FOLLOW_OFFSET_Y", line);
Expand All @@ -273,7 +273,7 @@ namespace {
if (value < -30) {
value = -30;
}
ssConfig.viewYoffset = value;
ssConfig.viewOffset.y = value;
}
if (line.find("[FOLLOW_OFFSET_Z") != string::npos) {
int value = parseIntFromLine("FOLLOW_OFFSET_Z", line);
Expand All @@ -283,7 +283,7 @@ namespace {
if (value < -30) {
value = -30;
}
ssConfig.viewZoffset = value;
ssConfig.viewOffset.z = value;
}
if (line.find("[BITMAP_HOLDS") != string::npos) {
int value = parseIntFromLine("BITMAP_HOLDS", line);
Expand Down Expand Up @@ -819,21 +819,19 @@ bool loadConfigFile()
auto path = std::filesystem::path{} / "dfhack-config" / "stonesense" / "init.txt";
std::ifstream myfile(path);
if (myfile.is_open() == false) {
LogError( "cannot find init file\n" );
LogError("cannot find init file\n");
return false;
}

while ( !myfile.eof() ) {
getline (myfile,line);
parseConfigLine( line );
while (!myfile.eof()) {
getline(myfile, line);
parseConfigLine(line);
}

// apply configuration settings to initial app state
stonesenseState.ssState.ScreenH = stonesenseState.ssConfig.defaultScreenHeight;
stonesenseState.ssState.ScreenW = stonesenseState.ssConfig.defaultScreenWidth;
stonesenseState.ssState.Size.x = stonesenseState.ssConfig.defaultSegmentSize.x + 2;
stonesenseState.ssState.Size.y = stonesenseState.ssConfig.defaultSegmentSize.y + 2;
stonesenseState.ssState.Size.z = stonesenseState.ssConfig.defaultSegmentSize.z;
stonesenseState.ssState.Size = stonesenseState.ssConfig.defaultSegmentSize + Crd3D{2, 2, 0};
stonesenseState.lift_segment_offscreen_x = 0;
stonesenseState.lift_segment_offscreen_y = stonesenseState.ssConfig.lift_segment;

Expand Down
2 changes: 1 addition & 1 deletion GUI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -950,7 +950,7 @@ void paintboard()
int top = 0;
if(ssConfig.track_mode != GameConfiguration::TRACKING_NONE) {
top += fontHeight;
draw_textf_border(font, uiColor(1), ssState.ScreenW/2,top, ALLEGRO_ALIGN_CENTRE, "Locked on DF screen + (%d,%d,%d)",ssConfig.viewXoffset,ssConfig.viewYoffset,ssConfig.viewZoffset);
draw_textf_border(font, uiColor(1), ssState.ScreenW/2,top, ALLEGRO_ALIGN_CENTRE, "Locked on DF screen + (%d,%d,%d)",ssConfig.viewOffset.x,ssConfig.viewOffset.y,ssConfig.viewOffset.z);
}
if(ssConfig.follow_DFcursor && ssConfig.debug_mode) {
top += fontHeight;
Expand Down
62 changes: 33 additions & 29 deletions GameConfiguration.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@

#include "allegro5/color.h"

// constexpr auto GFXMODE = GFX_AUTODETECT_WINDOWED;
constexpr auto DEFAULT_FULLSCREEN_MODE = false;
constexpr auto DEFAULT_RESOLUTION_WIDTH = 800;
constexpr auto DEFAULT_RESOLUTION_HEIGHT = 600;
constexpr auto DEFAULT_SIZE = /*20*/ 70;
constexpr auto DEFAULT_SIZE_Z = /*6*/ 4;

struct GameConfiguration {
enum trackingmode : uint8_t {
TRACKING_NONE,
Expand All @@ -25,45 +32,42 @@ struct GameConfiguration {
.y = DEFAULT_SIZE,
.z = DEFAULT_SIZE_Z
};
bool show_all_creatures;
int automatic_reload_time = 0;
int automatic_reload_step = 500;
bool show_all_creatures = false;
int automatic_reload_time = 50;
int automatic_reload_step = 50;
bool debug_mode = false;
bool transparentScreenshots;
bool transparentScreenshots = false;
int lift_segment = 0;
int animation_step = 300;
bool verbose_logging;
trackingmode track_mode = TRACKING_CENTER;
bool invert_mouse_z;
bool follow_DFcursor;
int animation_step = 196;
bool verbose_logging = false;
trackingmode track_mode = TRACKING_FOCUS;
bool invert_mouse_z = false;
bool follow_DFcursor = true;
bool show_creature_names = false;
bool show_creature_moods;
bool show_creature_jobs;
bool show_creature_moods = false;
bool show_creature_jobs = false;
uint8_t show_creature_professions;
bool names_use_nick;
bool names_use_species;
bool names_use_nick = true;
bool names_use_species = true;
bool show_osd = false;
bool cache_images;
bool show_stockpiles;
bool show_zones;
bool show_intro = true;
ALLEGRO_COLOR fogcol = al_map_rgba(255, 255, 255, 255);
bool cache_images = false;
bool show_stockpiles = true;
bool show_zones = true;
bool show_intro = false;
ALLEGRO_COLOR fogcol = al_map_rgba(128, 158, 177, 30);
bool fogenable = true;
ALLEGRO_COLOR backcol = al_map_rgb(95, 95, 160);
int viewXoffset;
int viewYoffset;
int viewZoffset;
ALLEGRO_COLOR backcol = al_map_rgb(128, 158, 177);
Crd3D viewOffset{ 0,0,0 };
int bitmapHolds = 4096;
bool saveImageCache;
bool saveImageCache = false;
int fontsize = 10;
std::filesystem::path font =
std::filesystem::path{ } / "data" / "art" / "font.ttf";
std::filesystem::path font = std::filesystem::path{ "DejaVuSans.ttf" };
bool useDfColors = false;
dfColors colors;
bool opengl;
bool directX;
bool software;
bool dayNightCycle;
bool opengl = false;
bool directX = false;
bool software = false;
bool dayNightCycle = false;
int imageCacheSize = 4096;
bool fog_of_war = true;

Expand Down
12 changes: 6 additions & 6 deletions TrackingModes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ void followCurrentDFCenter()
DFHack::Gui::getViewCoords(newviewx,newviewy,newviewz);
int32_t viewsizex = view_dims.map_x2 - view_dims.map_x1 + 1;
int32_t viewsizey = view_dims.map_y2 - view_dims.map_y1 + 1;
ssState.Position.x = newviewx + (viewsizex/2) - (ssState.Size.x / 2) + ssConfig.viewXoffset;
ssState.Position.y = newviewy + (viewsizey/2) - (ssState.Size.y / 2) + ssConfig.viewYoffset;
ssState.Position.z = newviewz + ssConfig.viewZoffset + 1;
ssState.Position.x = newviewx + (viewsizex/2) - (ssState.Size.x / 2) + ssConfig.viewOffset.x;
ssState.Position.y = newviewy + (viewsizey/2) - (ssState.Size.y / 2) + ssConfig.viewOffset.y;
ssState.Position.z = newviewz + ssConfig.viewOffset.z + 1;
}

//eventually, this should be a sort of "smart-follow" which switches modes intelligently
Expand All @@ -29,9 +29,9 @@ void followCurrentDFFocus()
auto& ssState = stonesenseState.ssState;

if(ssState.dfCursor.x != -30000) {
ssState.Position.x = ssState.dfCursor.x - (ssState.Size.x / 2) + ssConfig.viewXoffset;
ssState.Position.y = ssState.dfCursor.y - (ssState.Size.y / 2) + ssConfig.viewYoffset;
ssState.Position.z = ssState.dfCursor.z + ssConfig.viewZoffset + 1;
ssState.Position.x = ssState.dfCursor.x - (ssState.Size.x / 2) + ssConfig.viewOffset.x;
ssState.Position.y = ssState.dfCursor.y - (ssState.Size.y / 2) + ssConfig.viewOffset.y;
ssState.Position.z = ssState.dfCursor.z + ssConfig.viewOffset.z + 1;
} else {
followCurrentDFCenter();
}
Expand Down
12 changes: 6 additions & 6 deletions UserInput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ void moveViewRelativeToRotation( int stepx, int stepy )
auto& ssState = stonesenseState.ssState;

if (ssConfig.track_mode != GameConfiguration::TRACKING_NONE) {
changeRelativeToRotation(ssConfig.viewXoffset, ssConfig.viewYoffset, stepx, stepy );
changeRelativeToRotation(ssConfig.viewOffset.x, ssConfig.viewOffset.y, stepx, stepy );
}
//if we're following the DF screen, we DO NOT bound the view, since we have a simple way to get back
else {
Expand Down Expand Up @@ -322,9 +322,9 @@ void action_resetscreen(uint32_t keymod)
auto& ssState = stonesenseState.ssState;

if (ssConfig.track_mode != GameConfiguration::TRACKING_NONE) {
ssConfig.viewXoffset = 0;
ssConfig.viewYoffset = 0;
ssConfig.viewZoffset = 0;
ssConfig.viewOffset.x = 0;
ssConfig.viewOffset.y = 0;
ssConfig.viewOffset.z = 0;
} else {
ssState.Position.x = (ssState.RegionDim.x -ssState.Size.x)/2;
ssState.Position.y = (ssState.RegionDim.y -ssState.Size.y)/2;
Expand Down Expand Up @@ -583,7 +583,7 @@ void action_decrZ(uint32_t keymod)
ssConfig.track_mode = GameConfiguration::TRACKING_NONE;
}
if (ssConfig.track_mode != GameConfiguration::TRACKING_NONE) {
ssConfig.viewZoffset -= stepsize;
ssConfig.viewOffset.z -= stepsize;
} else {
ssState.Position.z -= stepsize;
}
Expand All @@ -607,7 +607,7 @@ void action_incrZ(uint32_t keymod)
ssConfig.track_mode = GameConfiguration::TRACKING_NONE;
}
if (ssConfig.track_mode != GameConfiguration::TRACKING_NONE) {
ssConfig.viewZoffset += stepsize;
ssConfig.viewOffset.z += stepsize;
} else {
ssState.Position.z += stepsize;
}
Expand Down
6 changes: 0 additions & 6 deletions common.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,6 @@ constexpr auto WALLHEIGHT = 32;
constexpr auto FLOORHEIGHT = 8;
#endif

// constexpr auto GFXMODE = GFX_AUTODETECT_WINDOWED;
constexpr auto DEFAULT_FULLSCREEN_MODE = false;
constexpr auto DEFAULT_RESOLUTION_WIDTH = 800;
constexpr auto DEFAULT_RESOLUTION_HEIGHT = 600;
// Height of a one pixel stripe of the wall of an entire tile,
// including wall and floor plate
constexpr auto TILEHEIGHT = (WALLHEIGHT + FLOORHEIGHT);
Expand All @@ -88,8 +84,6 @@ 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 MAPNAVIGATIONSTEP = 1;
constexpr auto MAPNAVIGATIONSTEPBIG = 10;

Expand Down
5 changes: 5 additions & 0 deletions commonTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,13 @@ struct Crd2D {
};
struct Crd3D {
int32_t x,y,z;
constexpr Crd3D operator+(const Crd3D rhs)
{
return Crd3D{ x + rhs.x, y + rhs.y, z + rhs.z };
}
};


class dfColors
{
public:
Expand Down

0 comments on commit 545f986

Please sign in to comment.