Skip to content

Commit

Permalink
Feature: configurable Ufopaedia facilities preview
Browse files Browse the repository at this point in the history
  • Loading branch information
WarStalkeR committed Feb 4, 2024
1 parent 91fc083 commit 7ebed32
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 9 deletions.
4 changes: 4 additions & 0 deletions src/Engine/Options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,10 @@ void create()
_info.push_back(OptionInfo("oxceShowBaseNameInPopups", &oxceShowBaseNameInPopups, false, "", "HIDDEN"));
_info.push_back(OptionInfo("oxceGeoscapeDebugLogMaxEntries", &oxceGeoscapeDebugLogMaxEntries, 1000, "", "HIDDEN"));
_info.push_back(OptionInfo("oxceGeoscapeEventsInstantDelivery", &oxceGeoscapeEventsInstantDelivery, true, "", "HIDDEN"));
_info.push_back(OptionInfo("oxcePediaFacilityMaxWidth", &oxcePediaFacilityMaxWidth, 2, "", "HIDDEN"));
_info.push_back(OptionInfo("oxcePediaFacilityMaxHeight", &oxcePediaFacilityMaxHeight, 2, "", "HIDDEN"));
_info.push_back(OptionInfo("oxcePediaFacilityOffsetX", &oxcePediaFacilityOffsetX, 0, "", "HIDDEN"));
_info.push_back(OptionInfo("oxcePediaFacilityOffsetY", &oxcePediaFacilityOffsetY, 0, "", "HIDDEN"));

// controls
_info.push_back(OptionInfo("keyOk", &keyOk, SDLK_RETURN, "STR_OK", "STR_GENERAL"));
Expand Down
4 changes: 4 additions & 0 deletions src/Engine/Options.inc.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,10 @@ OPT bool oxceDisableInventoryTuCost;
OPT bool oxceShowBaseNameInPopups;
OPT int oxceGeoscapeDebugLogMaxEntries;
OPT bool oxceGeoscapeEventsInstantDelivery;
OPT int oxcePediaFacilityMaxWidth;
OPT int oxcePediaFacilityMaxHeight;
OPT int oxcePediaFacilityOffsetX;
OPT int oxcePediaFacilityOffsetY;

// Flags and other stuff that don't need OptionInfo's.
OPT bool mute, reload, newOpenGL, newScaleFilter, newHQXFilter, newXBRZFilter, newRootWindowedMode, newFullscreen, newAllowResize, newBorderless;
Expand Down
18 changes: 9 additions & 9 deletions src/Ufopaedia/ArticleStateBaseFacility.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,11 @@ namespace OpenXcom

// build preview image
int tile_size = 32;
_image = new Surface(tile_size*2, tile_size*2, 232, 16);
_image = new Surface(
tile_size * std::max(1, Options::oxcePediaFacilityMaxWidth),
tile_size * std::max(1, Options::oxcePediaFacilityMaxHeight),
232 + Options::oxcePediaFacilityOffsetX,
16 + Options::oxcePediaFacilityOffsetY);
add(_image);

SurfaceSet *graphic = _game->getMod()->getSurfaceSet("BASEBITS.PCK");
Expand All @@ -73,15 +77,11 @@ namespace OpenXcom
int x_pos, y_pos;
int num;

if (facility->getSize()==1)
{
x_offset = y_offset = tile_size/2;
}
else
{
x_offset = y_offset = 0;
}
// calculate preview offset
x_offset = (tile_size * std::max(0, Options::oxcePediaFacilityMaxWidth - facility->getSize())) / 2;
y_offset = (tile_size * std::max(0, Options::oxcePediaFacilityMaxHeight - facility->getSize())) / 2;

// render build preview
num = 0;
y_pos = y_offset;
for (int y = 0; y < facility->getSize(); ++y)
Expand Down

0 comments on commit 7ebed32

Please sign in to comment.