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

Refactored out overlay mode #188

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
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
2 changes: 0 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ install(DIRECTORY ${CMAKE_SOURCE_DIR}/plugins/stonesense/configs/

SET(PROJECT_SRCS
TrackingModes.cpp
#Overlay.cpp
Tile.cpp
TileCondition.cpp
TileTree.cpp
Expand Down Expand Up @@ -64,7 +63,6 @@ SET(PROJECT_HDRS
MapLoading.h
MaterialMatcher.h
OcclusionTest.h
#Overlay.h
SegmentProcessing.h
SpriteColors.h
SpriteMaps.h
Expand Down
1 change: 0 additions & 1 deletion GUI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -946,7 +946,6 @@ void paintboard()
draw_textf_border(font, uiColor(1), 10, 3*fontHeight, 0, "Map Read Time: %.2fms", clockToMs(stonesenseState.stoneSenseTimers.read_time));
draw_textf_border(font, uiColor(1), 10, 4*fontHeight, 0, "Map Beautification Time: %.2fms", clockToMs(stonesenseState.stoneSenseTimers.beautify_time));
draw_textf_border(font, uiColor(1), 10, 5*fontHeight, 0, "Tile Sprite Assembly Time: %.2fms", clockToMs(stonesenseState.stoneSenseTimers.assembly_time));
draw_textf_border(font, uiColor(1), 10, 6*fontHeight, 0, "DF Renderer Overlay Time: %.2fms", clockToMs(stonesenseState.stoneSenseTimers.overlay_time));
draw_textf_border(font, uiColor(1), 10, 2*fontHeight, 0, "FPS: %.2f", 1000.0/clockToMs(stonesenseState.stoneSenseTimers.frame_total));
draw_textf_border(font, uiColor(1), 10, 7*fontHeight, 0, "Draw: %.2fms", clockToMs(stonesenseState.stoneSenseTimers.draw_time));
draw_textf_border(font, uiColor(1), 10, 9*fontHeight, 0, "%i/%i/%i, %i:%i", contentLoader->currentDay+1, contentLoader->currentMonth+1, contentLoader->currentYear, contentLoader->currentHour, (contentLoader->currentTickRel*60)/50);
Expand Down
2 changes: 1 addition & 1 deletion GameConfiguration.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ struct GameConfiguration {
Config config;

// items not configurable via the config file
bool overlay_mode;
bool immersive_mode;
bool show_designations = true;
bool show_announcements = false;
bool show_keybinds = false;
Expand Down
1 change: 0 additions & 1 deletion commonTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,6 @@ struct FrameTimers{
RollingAverage<float> beautify_time;
RollingAverage<float> assembly_time;
RollingAverage<float> draw_time;
RollingAverage<float> overlay_time;
RollingAverage<float> frame_total;

clock_t prev_frame_time{ clock() };
Expand Down
92 changes: 16 additions & 76 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
#include "commonTypes.h"

#include "Config.h"
//#include "Overlay.h"
#include "Tile.h"
#include "GUI.h"
//#include "SpriteMaps.h"
Expand Down Expand Up @@ -46,9 +45,6 @@ int keyoffset=0;

std::vector<DFHack::t_matgloss> v_stonetypes;

/*FIXME: Find a new replacement for the overlay mode.
std::unique_ptr<Overlay> overlay;
*/
ALLEGRO_DISPLAY * display;

ALLEGRO_EVENT event;
Expand Down Expand Up @@ -225,36 +221,6 @@ static void main_loop(ALLEGRO_DISPLAY * display, ALLEGRO_EVENT_QUEUE *queue, ALL

al_rest(0);

/*FIXME: Find a new replacement for the overlay mode.
if (ssConfig.overlay_mode)
{
bool goodoverlay = ovrlay->GoodViewscreen();
if (!goodoverlay) {
//do nothing; this isn't a view we can overlay
}if (ssConfig.spriteIndexOverlay) {
DrawSpriteIndexOverlay(ssConfig.currentSpriteOverlay);
ovrlay->Flip();
}
else if (!Maps::IsValid()) {
drawcredits();
ovrlay->Flip();
}
else if (timeToReloadSegment) {
reloadPosition();
al_clear_to_color(ssConfig.config.backcol);
paintboard();
ovrlay->Flip();
timeToReloadSegment = false;
animationFrameShown = true;
}
else if (animationFrameShown == false) {
al_clear_to_color(ssConfig.config.backcol);
paintboard();
ovrlay->Flip();
animationFrameShown = true;
}
}
else */
{
if (ssConfig.spriteIndexOverlay) {
DrawSpriteIndexOverlay(ssConfig.currentSpriteOverlay);
Expand All @@ -280,10 +246,8 @@ static void main_loop(ALLEGRO_DISPLAY * display, ALLEGRO_EVENT_QUEUE *queue, ALL
}
}

if (!ssConfig.overlay_mode) {
doMouse();
doRepeatActions();
}
doMouse();
doRepeatActions();
redraw = false;
}
/* Take the next event out of the event queue, and store it in `event'. */
Expand All @@ -302,9 +266,6 @@ static void main_loop(ALLEGRO_DISPLAY * display, ALLEGRO_EVENT_QUEUE *queue, ALL
if(in_time) {
switch (event.type) {
case ALLEGRO_EVENT_DISPLAY_RESIZE:
if (ssConfig.overlay_mode) {
break;
}
stonesenseState.timeToReloadSegment = true;
redraw = true;
stonesenseState.ssState.ScreenH = event.display.height;
Expand All @@ -317,9 +278,6 @@ static void main_loop(ALLEGRO_DISPLAY * display, ALLEGRO_EVENT_QUEUE *queue, ALL
/* ALLEGRO_EVENT_KEY_DOWN - a keyboard key was pressed.
*/
case ALLEGRO_EVENT_KEY_CHAR:
if (ssConfig.overlay_mode) {
break;
}
if(event.keyboard.display != display) {
break;
}
Expand Down Expand Up @@ -394,9 +352,9 @@ static void* stonesense_thread(ALLEGRO_THREAD* main_thread, void* parms)

auto& ssConfig = stonesenseState.ssConfig;
al_set_new_display_flags(
(ssConfig.config.Fullscreen && !ssConfig.overlay_mode ? ALLEGRO_FULLSCREEN : ALLEGRO_WINDOWED)
|(ssConfig.overlay_mode ? 0 : ALLEGRO_RESIZABLE)
|(ssConfig.overlay_mode ? ALLEGRO_MINIMIZED : 0)
(ssConfig.config.Fullscreen ? ALLEGRO_FULLSCREEN : ALLEGRO_WINDOWED)
|(ALLEGRO_RESIZABLE)
|(0)
|(ssConfig.config.opengl ? ALLEGRO_OPENGL : 0)
|(ssConfig.config.directX ? ALLEGRO_DIRECT3D_INTERNAL : 0));

Expand Down Expand Up @@ -437,12 +395,6 @@ static void* stonesense_thread(ALLEGRO_THREAD* main_thread, void* parms)
SetTitle("Stonesense");
drawcredits();

/*FIXME: Find a new replacement for the overlay mode.
if(ssConfig.overlay_mode){
overlay = std::make_unique<Overlay>(df::global::enabler->renderer);
df::global::enabler->renderer = overlay.get();
}
*/

std::filesystem::path p = std::filesystem::path{} / "stonesense" / "stonesense.png";
IMGIcon = load_bitmap_withWarning(p);
Expand Down Expand Up @@ -502,9 +454,6 @@ static void* stonesense_thread(ALLEGRO_THREAD* main_thread, void* parms)
// window is destroyed.
al_destroy_display(display);
display = 0;
/*FIXME: Find a new replacement for the overlay mode.
overlay.reset();
*/

if(ssConfig.threadmade) {
al_broadcast_cond(ssConfig.readCond);
Expand Down Expand Up @@ -556,31 +505,22 @@ DFhackCExport command_result plugin_shutdown ( color_ostream &out )
//and the actual stonesense command. Maybe.
DFhackCExport command_result stonesense_command(color_ostream &out, std::vector<std::string> & params)
{
/*
if (!init->display.flag.is_set(init_display_flags::RENDER_2D) &&
!params.empty() && params[0] == "overlay")
{
out.printerr("'stonesense overlay' is not supported in this print mode.\n"
"Try changing PRINT_MODE to 2D or a similar choice in init.txt.\n");
return CR_FAILURE;
}
#ifdef _DARWIN
if (!init->display.flag.is_set(init_display_flags::RENDER_2D))
{
out.printerr("The current print mode is not suported\n"
"Change PRINT_MODE in init.txt to 2D or a similar choice\n");
return CR_FAILURE;
}
#endif
*/
if(stonesense_started) {
out.print("Stonesense already running.\n");
return CR_OK;
}
stonesenseState.ssConfig.overlay_mode = false;
stonesenseState.ssConfig.immersive_mode = false;
if(params.size() > 0 ) {
if(params[0] == "overlay"){
//ssConfig.overlay_mode = true;
if(params[0] == "immersive"){
auto focusStr = DFHack::Gui::getCurFocus().front();
if (!(focusStr.starts_with("title") ||
focusStr.starts_with("loadgame"))) {
out.print(
"You need to start this mode from the titlescreen and enable keyboard cursor (in settings) to ensure a proper state."
);
return CR_OK;
}
stonesenseState.ssConfig.immersive_mode = true;
} else {
DumpInfo(out, params);
return CR_OK;
Expand Down