Skip to content

Commit a397539

Browse files
authored
Merge pull request #1606 from falbrechtskirchinger/pin-windows
Allow excluding windows from being closed via Escape key
2 parents ff0589e + 0385e10 commit a397539

17 files changed

Lines changed: 339 additions & 31 deletions

File tree

822 Bytes
Binary file not shown.
822 Bytes
Binary file not shown.
822 Bytes
Binary file not shown.
822 Bytes
Binary file not shown.
822 Bytes
Binary file not shown.
822 Bytes
Binary file not shown.

libs/s25main/Loader.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include "ogl/glArchivItem_Bitmap_RLE.h"
2222
#include "ogl/glArchivItem_Bitmap_Raw.h"
2323
#include "ogl/glArchivItem_Bob.h"
24+
#include "ogl/glArchivItem_Sound_Wave.h"
2425
#include "ogl/glFont.h"
2526
#include "ogl/glSmartBitmap.h"
2627
#include "ogl/glTexturePacker.h"
@@ -385,6 +386,17 @@ void Loader::LoadDummyMapFiles()
385386
}
386387
}
387388

389+
void Loader::LoadDummySoundFiles()
390+
{
391+
libsiedler2::Archiv& archive = files_["sound"].archive;
392+
archive.alloc(116);
393+
for(unsigned id = 51; id < archive.size(); id++)
394+
{
395+
auto snd = std::make_unique<glArchivItem_Sound_Wave>();
396+
archive.set(id, std::move(snd));
397+
}
398+
}
399+
388400
namespace {
389401
struct NationResourcesSource
390402
{

libs/s25main/Loader.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ class Loader
8686
/// Creates archives with empty files for the GUI (for testing purposes)
8787
void LoadDummyGUIFiles();
8888
void LoadDummyMapFiles();
89+
void LoadDummySoundFiles();
8990
/// Load a file and save it into the loader repo
9091
bool Load(const boost::filesystem::path& path, const libsiedler2::ArchivItem_Palette* palette = nullptr);
9192
bool Load(const ResourceId& resId, const libsiedler2::ArchivItem_Palette* palette = nullptr);

libs/s25main/Settings.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ void Settings::LoadDefaults()
139139
// {
140140
interface.autosave_interval = 0;
141141
interface.revert_mouse = false;
142+
interface.enableWindowPinning = false;
142143
// }
143144

144145
// addons
@@ -296,6 +297,7 @@ void Settings::Load()
296297
// {
297298
interface.autosave_interval = iniInterface->getIntValue("autosave_interval");
298299
interface.revert_mouse = iniInterface->getBoolValue("revert_mouse");
300+
interface.enableWindowPinning = iniInterface->getValue("enable_window_pinning", false);
299301
// }
300302

301303
// addons
@@ -353,6 +355,7 @@ void Settings::LoadIngame()
353355
settings.restorePos = DrawPoint(iniWindow->getValue("restore_pos_x", lastPos.x),
354356
iniWindow->getValue("restore_pos_y", lastPos.y));
355357
settings.isOpen = iniWindow->getIntValue("is_open");
358+
settings.isPinned = iniWindow->getValue("is_pinned", false);
356359
settings.isMinimized = iniWindow->getValue("is_minimized", false);
357360
}
358361
} catch(std::runtime_error& e)
@@ -456,6 +459,7 @@ void Settings::Save()
456459
// {
457460
iniInterface->setValue("autosave_interval", interface.autosave_interval);
458461
iniInterface->setValue("revert_mouse", interface.revert_mouse);
462+
iniInterface->setValue("enable_window_pinning", interface.enableWindowPinning);
459463
// }
460464

461465
// addons
@@ -513,6 +517,7 @@ void Settings::SaveIngame()
513517
iniWindow->setValue("restore_pos_y", settings.restorePos.y);
514518
}
515519
iniWindow->setValue("is_open", settings.isOpen);
520+
iniWindow->setValue("is_pinned", settings.isPinned);
516521
iniWindow->setValue("is_minimized", settings.isMinimized);
517522
}
518523

libs/s25main/Settings.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ struct PersistentWindowSettings
2727
DrawPoint lastPos = DrawPoint::Invalid();
2828
DrawPoint restorePos = DrawPoint::Invalid();
2929
bool isOpen = false;
30+
bool isPinned = false;
3031
bool isMinimized = false;
3132
};
3233

@@ -104,6 +105,7 @@ class Settings : public Singleton<Settings, SingletonPolicies::WithLongevity>
104105
{
105106
unsigned autosave_interval;
106107
bool revert_mouse;
108+
bool enableWindowPinning;
107109
} interface;
108110

109111
struct

0 commit comments

Comments
 (0)