[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Wesnoth-cvs-commits] wesnoth src/theme.cpp data/themes/default.cfg
From: |
Yann Dirson |
Subject: |
[Wesnoth-cvs-commits] wesnoth src/theme.cpp data/themes/default.cfg |
Date: |
Fri, 10 Dec 2004 20:35:50 -0500 |
CVSROOT: /cvsroot/wesnoth
Module name: wesnoth
Branch:
Changes by: Yann Dirson <address@hidden> 04/12/11 01:25:10
Modified files:
src : theme.cpp
data/themes : default.cfg
Log message:
implemented [partialresolution] for theme inheritance; use it to define
800x600 in a much more compact way
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/theme.cpp.diff?tr1=1.24&tr2=1.25&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/data/themes/default.cfg.diff?tr1=1.71&tr2=1.72&r1=text&r2=text
Patches:
Index: wesnoth/data/themes/default.cfg
diff -u wesnoth/data/themes/default.cfg:1.71
wesnoth/data/themes/default.cfg:1.72
--- wesnoth/data/themes/default.cfg:1.71 Wed Dec 8 23:11:16 2004
+++ wesnoth/data/themes/default.cfg Sat Dec 11 01:25:10 2004
@@ -10,6 +10,7 @@
name=Default
[resolution]
+id=1024x768
width=1024
height=768
@@ -58,6 +59,7 @@
[/panel]
[menu]
+ id=menu-main
title= _ "Menu"
image=lite
items=objectives,statistics,unitlist,separator,statustable,save,load,preferences,chatlog,help,quit
@@ -257,6 +259,7 @@
prefix_literal=""
[/num_units]
[upkeep]
+ id=status-upkeep
font_size=12
ref=upkeep-icon
rect=+4,=,+40,+16
@@ -266,6 +269,7 @@
prefix_literal=""
[/upkeep]
[income]
+ id=status-income
font_size=12
ref=income-icon
rect=+4,=,+40,+16
@@ -275,12 +279,14 @@
prefix_literal=""
[/income]
[terrain]
+ id=status-terrain
font_size=12
rect=+5,=,+120,+16
xanchor=proportional
yanchor=fixed
[/terrain]
[position]
+ id=status-position
font_size=12
rect=+5,=,+105,+16
xanchor=proportional
@@ -377,349 +383,51 @@
yanchor=fixed
[/unit_weapons]
[/status]
-
- [dummy]
- id=dummy2
- [/dummy]
[/resolution]
-[resolution]
+[partialresolution]
+id=800x600
+inherits=1024x768
width=800
height=600
- # top panel
- [panel]
- image=misc/top-bg.png
- rect=0,0,1024,26
- xanchor=top
- yanchor=fixed
- [/panel]
-
- [main_map]
- rect=0,26,882,768
- xanchor=left
- yanchor=top
- [/main_map]
-
- # rightside panel
- [panel]
- image=misc/rightside.png
- rect=882,25,1024,309
- xanchor=right
- yanchor=fixed
- [/panel]
- [panel]
- image=misc/rightside-bg.png
- rect=882,309,1024,730
- xanchor=right
- yanchor=top
- [/panel]
- [panel]
- image=misc/rightside-bottom.png
- rect=882,730,0,768
- xanchor=right
- yanchor=bottom
- [/panel]
-
- [menu]
- title= _ "Menu"
- image=lite
+ [change]
+ id=menu-main
items=objectives,statistics,unitlist,statustable,save,load,preferences,chatlog,help,quit
- rect=3,1,103,22
- xanchor=fixed
- yanchor=fixed
- [/menu]
-
- [menu]
- title= _ "Actions"
- image=lite
-
items=undo,redo,cycle,speak,recruit,recall,showenemymoves,bestenemymoves,delayshroud,updateshroud,endturn
- rect=105,1,205,22
- xanchor=fixed
- yanchor=fixed
- [/menu]
-
- [menu]
- is_context_menu=true
-
items=undo,redo,describeunit,renameunit,createunit,changeside,labelterrain,speak,continue,recruit,recall,delayshroud,updateshroud,cycle,endturn
- [/menu]
- [mini_map]
- rect=892,32,1017,175
- xanchor=right
- yanchor=fixed
- [/mini_map]
-
- [menu]
- title= _ "End Turn"
- items=endturn
- rect=900,737
- xanchor=right
- yanchor=bottom
- [/menu]
-
- [panel]
- image=misc/status-bg.png
- rect=270,2,365,21
- xanchor=proportional
- yanchor=fixed
- [/panel]
- [panel]
- image=misc/status-bg.png
- rect=370,2,465,21
- xanchor=proportional
- yanchor=fixed
- [/panel]
- [panel]
- image=misc/status-bg.png
- rect=470,2,555,21
- xanchor=proportional
- yanchor=fixed
- [/panel]
- [panel]
- image=misc/status-bg.png
- rect=560,2,645,21
- xanchor=proportional
- yanchor=fixed
- [/panel]
- [panel]
- image=misc/status-bg.png
- rect=650,2,750,21
- xanchor=proportional
- yanchor=fixed
- [/panel]
- [panel]
- image=misc/status-bg.png
- rect=755,2,844,21
- xanchor=proportional
- yanchor=fixed
- [/panel]
-
- # HP/XP
- [label]
- font_size=10
- text= _ "HP"
- rect=967,234,1022,246
- xanchor=right
- yanchor=fixed
- [/label]
- [label]
- font_size=10
- text= _ "XP"
- rect=967,260,1022,272
- xanchor=right
- yanchor=fixed
- [/label]
-
- # gold icon
- [label]
- icon=misc/gold.png
- text= _ "gold"
- rect=375,3,391,19
- xanchor=proportional
- yanchor=fixed
- [/label]
- # villages icon
- [label]
- icon=misc/villages.png
- text= _ "villages"
- rect=475,3,491,19
- xanchor=proportional
- yanchor=fixed
- [/label]
- # units icon
- [label]
- icon=misc/units.png
- text= _ "units"
- rect=565,3,581,19
- xanchor=proportional
- yanchor=fixed
- [/label]
- # upkeep icon
- [label]
- icon=misc/upkeep.png
- text= _ "upkeep"
- rect=655,3,687,19
- xanchor=proportional
- yanchor=fixed
- [/label]
- # income icon
- [label]
- icon=misc/income.png
- text= _ "income"
- rect=760,3,792,19
- xanchor=proportional
- yanchor=fixed
- [/label]
-
- [status]
- # the time of day image
- [time_of_day]
- rect=892,184,1017,223
- xanchor=right
- yanchor=fixed
- [/time_of_day]
-
- [observers]
- font_size=12
- rect=1004,3,1020,19
- xanchor=proportional
- yanchor=fixed
- [/observers]
+ [/change]
- #put the side playing indicator next to the turn indicator
- [side_playing]
- rect=273,4,288,20
- xanchor=proportional
- yanchor=fixed
- [/side_playing]
+ [change]
+ id=turn-panel
+ rect=+65,=+1,+95,+19
+ [/change]
- # the game status
- [turn]
- font_size=12
- rect=292,4,360,20
- xanchor=proportional
- yanchor=fixed
- prefix=
- prefix_literal=""
- [/turn]
- [gold]
- font_size=12
- rect=395,4,460,20
- xanchor=proportional
- yanchor=fixed
- prefix=
- prefix_literal=""
- [/gold]
- [villages]
- font_size=12
- rect=495,4,550,20
- xanchor=proportional
- yanchor=fixed
- prefix=
- prefix_literal=""
- [/villages]
- [num_units]
- font_size=12
- rect=585,4,640,20
- xanchor=proportional
- yanchor=fixed
- prefix=
- prefix_literal=""
- [/num_units]
- [upkeep]
- font_size=12
- rect=690,4,745,20
- xanchor=proportional
- yanchor=fixed
- prefix=
- prefix_literal=""
- [/upkeep]
- [income]
- font_size=12
- rect=795,4,840,20
- xanchor=proportional
- yanchor=fixed
- prefix=
- prefix_literal=""
- [/income]
- [comment]
- [terrain]
- font_size=12
- rect=770,4,890,20
- xanchor=proportional
- yanchor=fixed
- [/terrain]
- [/comment]
- [position]
- font_size=12
- rect=855,4,1000,20
- xanchor=proportional
- yanchor=fixed
- [/position]
+ [change]
+ id=upkeep-panel
+ rect=+5,=,+100,=
+ [/change]
+ [change]
+ id=income-panel
+ rect=+5,=,+89,=
+ [/change]
- #unit stats here
- [unit_image]
- rect=891,235,963,307
- xanchor=right
- yanchor=fixed
- [/unit_image]
- [unit_description]
- font_size=14
- rect=891,312,1022,330
- xanchor=right
- yanchor=fixed
- [/unit_description]
- [unit_type]
- font_size=12
- rect=891,330,1022,346
- xanchor=right
- yanchor=fixed
- [/unit_type]
- [unit_level]
- font_size=12
- rect=891,346,1022,362
- prefix= _ "statuspanel^level"
- prefix_literal=" "
- xanchor=right
- yanchor=fixed
- [/unit_level]
- [unit_alignment]
- font_size=12
- rect=891,362,1022,378
- xanchor=right
- yanchor=fixed
- [/unit_alignment]
- [unit_traits]
- font_size=12
- rect=891,378,1022,394
- xanchor=right
- yanchor=fixed
- [/unit_traits]
- [unit_abilities]
- font_size=12
- rect=891,394,1022,410
- xanchor=right
- yanchor=fixed
- [/unit_abilities]
- [unit_status]
- font_size=12
- rect=968,289,1020,305
- xanchor=right
- yanchor=fixed
- [/unit_status]
- [unit_moves]
- font_size=12
- rect=891,410,1022,426
- prefix= _ "statuspanel^movement"
- prefix_literal=": "
- xanchor=right
- yanchor=fixed
- [/unit_moves]
- [unit_hp]
- font_size=12
- rect=967,246,1022,260
- #prefix=hp
- #prefix_literal=" "
- xanchor=right
- yanchor=fixed
- [/unit_hp]
- [unit_xp]
- font_size=12
- rect=967,272,1022,286
- #prefix=xp
- #prefix_literal=" "
- xanchor=right
- yanchor=fixed
- [/unit_xp]
- [unit_weapons]
- font_size=12
- #rect=900,452,1020,620
- rect=891,426,1022,594
- xanchor=right
- yanchor=fixed
- [/unit_weapons]
- [/status]
-[/resolution]
+ [change]
+ id=status-upkeep
+ rect=+4,=,+55,+16
+ [/change]
+ [change]
+ id=status-income
+ rect=+3,=,+45,+16
+ [/change]
+
+ [remove]
+ id=status-terrain
+ [/remove]
+
+ [change]
+ id=status-position
+ rect=+15,=,+145,+16
+ [/change]
+[/partialresolution]
[resolution]
width=320
Index: wesnoth/src/theme.cpp
diff -u wesnoth/src/theme.cpp:1.24 wesnoth/src/theme.cpp:1.25
--- wesnoth/src/theme.cpp:1.24 Wed Dec 8 22:59:26 2004
+++ wesnoth/src/theme.cpp Sat Dec 11 01:25:10 2004
@@ -90,32 +90,93 @@
return resolved.str();
}
- const config find_ref(const std::string& id, const config& resol_cfg) {
- for(config::all_children_iterator i = resol_cfg.ordered_begin();
- i != resol_cfg.ordered_end(); i++) {
- if ((*(*i).second)["id"] == id) {
- //std::cerr << "Found a " << *(*i).first <<
"\n";
- return *(*i).second;
- }
- // recursively look in children
- const config c = find_ref(id, *(*i).second);
- if (!c["id"].empty()) {
- return c;
+ config empty_config = config();
+
+ config& find_ref(const std::string& id, config& cfg, bool remove =
false) {
+ for(config::child_map::const_iterator i =
cfg.all_children().begin();
+ i != cfg.all_children().end(); i++) {
+ for (config::child_list::const_iterator j =
i->second.begin();
+ j != i->second.end(); j++) {
+ if ((**j)["id"] == id) {
+ //std::cerr << "Found a " <<
*(*i).first << "\n";
+ if (remove) {
+ const config* const res =
cfg.find_child((*i).first,"id",id);
+ const size_t index =
std::find((*i).second.begin(), (*i).second.end(),
+
res) - (*i).second.begin();
+
cfg.remove_child((*i).first,index);
+ return empty_config;
+ } else {
+ return **j;
+ }
+ }
+
+ // recursively look in children
+ config& c = find_ref(id, **j, remove);
+ if (!c["id"].empty()) {
+ return c;
+ }
}
}
// not found
- return config();
+ return empty_config;
+ }
+
+#ifdef DEBUG
+ // to be called from gdb
+ config& find_ref(const char* id, config& cfg) {
+ return find_ref(std::string(id),cfg);
+ }
+#endif
+
+ config* expand_partialresolution(const config& cfg, const config&
topcfg) {
+ // start with a copy of the declared parent
+ config* outcfg = new config(*topcfg.find_child("resolution",
"id", cfg["inherits"]));
+
+ // override attributes
+ for(string_map::const_iterator j = cfg.values.begin(); j !=
cfg.values.end(); ++j) {
+ outcfg->values[j->first] = j->second;
+ }
+
+ // apply operations
+ {
+ const config::child_list& c =
cfg.get_children("remove");
+ for(config::child_list::const_iterator i = c.begin(); i
!= c.end(); ++i) {
+ const config* parent;
+ config& target = find_ref ((**i)["id"],
*outcfg, true);
+ }
+ }
+ {
+ const config::child_list& c =
cfg.get_children("change");
+ for(config::child_list::const_iterator i = c.begin(); i
!= c.end(); ++i) {
+ config& target = find_ref ((**i)["id"],
*outcfg);
+ for(string_map::iterator j =
(**i).values.begin();
+ j != (**i).values.end(); ++j) {
+ target.values[j->first] = j->second;
+ }
+ }
+ }
+
+ return outcfg;
}
void do_resolve_rects(const config& cfg, config& resolved_config,
- config* resol_cfg = NULL) {
+ const config& topcfg, config* resol_cfg = NULL) {
// recursively resolve children
for(config::all_children_iterator i = cfg.ordered_begin(); i !=
cfg.ordered_end(); ++i) {
const std::pair<const std::string*,const config*>&
value = *i;
- config& childcfg =
resolved_config.add_child(*value.first);
- do_resolve_rects(*value.second, childcfg,
- (*value.first=="resolution") ?
&childcfg : resol_cfg);
+ const std::string* childname = value.first;
+ const config* sourceconfig = value.second;
+ if (*value.first == "partialresolution") {
+ childname = new std::string("resolution");
+ sourceconfig = expand_partialresolution
(*sourceconfig, topcfg);
+ //std::cerr << sourceconfig->write();
+ }
+ config& childcfg =
resolved_config.add_child(*childname);
+ do_resolve_rects(*sourceconfig, childcfg, topcfg,
+ (*childname=="resolution") ? &childcfg
: resol_cfg);
+
+ if (childname != value.first) delete childname;
}
// copy all key/values
@@ -150,7 +211,7 @@
config& resolve_rects(const config& cfg) {
config* newcfg = new config();
- do_resolve_rects(cfg, *newcfg);
+ do_resolve_rects(cfg, *newcfg, cfg);
return *newcfg;
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Wesnoth-cvs-commits] wesnoth src/theme.cpp data/themes/default.cfg,
Yann Dirson <=