mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-10 13:06:59 -04:00
implemented most of DataEditor; fixed some bugs in Settings
git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@78 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
+27
-7
@@ -8,6 +8,7 @@
|
||||
|
||||
#include <data/settings.hpp>
|
||||
#include <data/game.hpp>
|
||||
#include <data/stylesheet.hpp>
|
||||
#include <data/field.hpp>
|
||||
#include <util/reflect.hpp>
|
||||
#include <util/io/reader.hpp>
|
||||
@@ -39,6 +40,10 @@ IMPLEMENT_REFLECTION(ColumnSettings) {
|
||||
REFLECT(visible);
|
||||
}
|
||||
|
||||
GameSettings::GameSettings()
|
||||
: sort_cards_ascending(true)
|
||||
{}
|
||||
|
||||
IMPLEMENT_REFLECTION(GameSettings) {
|
||||
REFLECT(default_stylesheet);
|
||||
REFLECT(default_export);
|
||||
@@ -47,6 +52,23 @@ IMPLEMENT_REFLECTION(GameSettings) {
|
||||
REFLECT(sort_cards_ascending);
|
||||
}
|
||||
|
||||
|
||||
StyleSheetSettings::StyleSheetSettings()
|
||||
: card_zoom (1.0, true)
|
||||
, card_angle (0, true)
|
||||
, card_anti_alias (true, true)
|
||||
, card_borders (true, true)
|
||||
, card_normal_export(true, true)
|
||||
{}
|
||||
|
||||
void StyleSheetSettings::useDefault(const StyleSheetSettings& ss) {
|
||||
if (card_zoom .isDefault()) card_zoom .assignDefault(ss.card_zoom());
|
||||
if (card_angle .isDefault()) card_angle .assignDefault(ss.card_angle());
|
||||
if (card_anti_alias .isDefault()) card_anti_alias .assignDefault(ss.card_anti_alias());
|
||||
if (card_borders .isDefault()) card_borders .assignDefault(ss.card_borders());
|
||||
if (card_normal_export.isDefault()) card_normal_export.assignDefault(ss.card_normal_export());
|
||||
}
|
||||
|
||||
IMPLEMENT_REFLECTION(StyleSheetSettings) {
|
||||
REFLECT(card_zoom);
|
||||
REFLECT(card_angle);
|
||||
@@ -85,7 +107,7 @@ void Settings::addRecentFile(const String& filename) {
|
||||
}
|
||||
|
||||
GameSettings& Settings::gameSettingsFor(const Game& game) {
|
||||
GameSettingsP& gs = settings.game_settings[game.name()];
|
||||
GameSettingsP& gs = game_settings[game.name()];
|
||||
if (!gs) gs.reset(new GameSettings);
|
||||
return *gs;
|
||||
}
|
||||
@@ -102,14 +124,12 @@ ColumnSettings& Settings::columnSettingsFor(const Game& game, const Field& field
|
||||
}
|
||||
return cs;
|
||||
}
|
||||
/*
|
||||
StyleSettings& Settings::styleSettingsFor(const CardStyle& style) {
|
||||
StyleSettingsP& ss = settings.styleSettings#(style.name());
|
||||
if (!ss) ss = new_shared<StyleSettings>();
|
||||
ss->useDefault(defaultStyleSettings); // update default settings
|
||||
StyleSheetSettings& Settings::stylesheetSettingsFor(const StyleSheet& stylesheet) {
|
||||
StyleSheetSettingsP& ss = stylesheet_settings[stylesheet.name()];
|
||||
if (!ss) ss.reset(new StyleSheetSettings);
|
||||
ss->useDefault(default_stylesheet_settings); // update default settings
|
||||
return *ss;
|
||||
}
|
||||
*/
|
||||
|
||||
String user_settings_dir() {
|
||||
return _(""); // TODO
|
||||
|
||||
@@ -43,6 +43,8 @@ class ColumnSettings {
|
||||
/// Settings for a Game
|
||||
class GameSettings {
|
||||
public:
|
||||
GameSettings();
|
||||
|
||||
String default_stylesheet;
|
||||
String default_export;
|
||||
map<String, ColumnSettings> columns;
|
||||
@@ -55,6 +57,8 @@ class GameSettings {
|
||||
/// Settings for a StyleSheet
|
||||
class StyleSheetSettings {
|
||||
public:
|
||||
StyleSheetSettings();
|
||||
|
||||
// Rendering/display settings
|
||||
Defaultable<double> card_zoom;
|
||||
Defaultable<int> card_angle;
|
||||
@@ -62,10 +66,10 @@ class StyleSheetSettings {
|
||||
Defaultable<bool> card_borders;
|
||||
Defaultable<bool> card_normal_export;
|
||||
|
||||
DECLARE_REFLECTION();
|
||||
/// Where the settings are the default, use the value from ss
|
||||
void useDefault(const StyleSheetSettings& ss);
|
||||
|
||||
// /// Where the settings are the default, use the value from ss
|
||||
// void useDefault(const StyleSheetSettings& ss);
|
||||
DECLARE_REFLECTION();
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------- : Settings
|
||||
@@ -102,7 +106,7 @@ class Settings {
|
||||
/// Get the settings for a column for a specific field in a game
|
||||
ColumnSettings& columnSettingsFor (const Game& game, const Field& field);
|
||||
/// Get the settings object for a specific stylesheet
|
||||
StyleSheetSettings& styleSheetSettingsFor(const StyleSheet& stylesheet);
|
||||
StyleSheetSettings& stylesheetSettingsFor(const StyleSheet& stylesheet);
|
||||
|
||||
private:
|
||||
map<String,GameSettingsP> game_settings;
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
|
||||
#include <util/prec.hpp>
|
||||
#include <util/io/package.hpp>
|
||||
#include <util/real_point.hpp>
|
||||
#include <script/scriptable.hpp>
|
||||
|
||||
DECLARE_POINTER_TYPE(Game);
|
||||
@@ -47,6 +48,8 @@ class StyleSheet : public Packaged {
|
||||
|
||||
bool dependencies_initialized; ///< are the script dependencies comming from this stylesheet all initialized?
|
||||
|
||||
inline RealRect getCardRect() const { return RealRect(0, 0, card_width, card_height); }
|
||||
|
||||
/// Load a StyleSheet, given a Game and the name of the StyleSheet
|
||||
static StyleSheetP byGameAndName(const Game& game, const String& name);
|
||||
/// name of the package without the game name
|
||||
|
||||
Reference in New Issue
Block a user