[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Windstille-devel] rev 372 - trunk/src
From: |
Ingo Ruhnke |
Subject: |
[Windstille-devel] rev 372 - trunk/src |
Date: |
Mon, 31 May 2004 11:57:13 +0200 |
Author: grumbel
Date: 2004-05-31 11:57:12 +0200 (Mon, 31 May 2004)
New Revision: 372
Modified:
trunk/src/clanlib.i
trunk/src/editor.py
trunk/src/minimap.cxx
trunk/src/supertux.py
Log:
- fixed minimap position
- added config file support
Modified: trunk/src/clanlib.i
===================================================================
--- trunk/src/clanlib.i 2004-05-30 19:21:30 UTC (rev 371)
+++ trunk/src/clanlib.i 2004-05-31 09:57:12 UTC (rev 372)
@@ -55,6 +55,7 @@
public:
CL_Component(CL_Component* parent, CL_StyleManager* style = NULL);
void show(bool show = true);
+ bool is_visible(bool check_parents = true);
};
class CL_Window : public CL_Component
Modified: trunk/src/editor.py
===================================================================
--- trunk/src/editor.py 2004-05-30 19:21:30 UTC (rev 371)
+++ trunk/src/editor.py 2004-05-31 09:57:12 UTC (rev 372)
@@ -21,8 +21,6 @@
import sys
from flexlay import *
-recent_files = []
-
flexlay = Flexlay()
flexlay.init()
@@ -49,7 +47,7 @@
EditorMap.get_metadata = EditorMap_get_metadata
del EditorMap_get_metadata
-myrect = CL_Rect(CL_Point(0, 56), CL_Size(665, 488))
+myrect = CL_Rect(CL_Point(0, 56), CL_Size(665, 488+56))
editor_map = EditorMapComponent(myrect, gui.get_component())
workspace = Workspace(myrect.get_width(), myrect.get_height())
editor_map.set_workspace(workspace)
@@ -118,6 +116,12 @@
def gui_level_load():
load_dialog.run(supertux_load_level)
+def gui_toggle_minimap():
+ if minimap.is_visible():
+ minimap.show(False)
+ else:
+ minimap.show(True)
+
class Counter:
counter = 0;
@@ -162,6 +166,10 @@
undo_icon.disable()
redo_icon.disable()
+minimap_icon = Icon(CL_Rect(CL_Point(p.inc(48), 2), CL_Size(32, 32)),
+ make_sprite("../data/images/icons24/minimap.png"), "Some
tooltip", willow);
+minimap_icon.set_callback(gui_toggle_minimap)
+
foreground_icon = Icon(CL_Rect(CL_Point(p.inc(48), 2), CL_Size(32, 32)),
make_sprite("../data/images/icons24/foreground.png"),
"Some tooltip", willow);
interactive_icon = Icon(CL_Rect(CL_Point(p.inc(32), 2), CL_Size(32, 32)),
@@ -316,6 +324,8 @@
workspace.get_map().get_metadata().save(filename)
recent_files_menu = Menu(CL_Point(32*2, 54), gui.get_component())
+for filename in config.recent_files:
+ recent_files_menu.add_item(mysprite, filename, lambda:
supertux_load_level(filename))
def has_element(lst, el):
for i in lst:
@@ -329,10 +339,12 @@
level.activate(workspace)
connect(level.editormap.sig_change(), on_map_change)
- if not(has_element(recent_files, filename)):
- recent_files.append(filename)
+ if not(has_element(config.recent_files, filename)):
+ config.recent_files.append(filename)
recent_files_menu.add_item(mysprite, filename, lambda:
supertux_load_level(filename))
+ minimap.update_minimap()
+
menu = CL_Menu(gui.get_component())
menu.add_item("File/Open...", gui_level_load)
menu.add_item("File/Save...", gui_level_save)
@@ -358,8 +370,8 @@
paste_icon.set_callback(show_menu)
-minimap_panel = Panel(CL_Rect(CL_Point(0, 600-56), CL_Size(800-134, 56)),
gui.get_component())
-minimap = Minimap(editor_map, CL_Rect(CL_Point(3, 3), CL_Size(794-134, 50)),
minimap_panel)
+# minimap_panel = Panel(CL_Rect(CL_Point(0, 600-56), CL_Size(800-134, 56)),
gui.get_component())
+minimap = Minimap(editor_map, CL_Rect(CL_Point(3, 488+3-14),
CL_Size(794-134-16, 50)), editor_map)
class FileDialog:
window = None
@@ -401,9 +413,9 @@
print "DoSomething: ", filename
load_dialog = FileDialog("Load SuperTux Level", "Load", "Cancel",
gui.get_component())
-load_dialog.set_filename(supertux_datadir + "levels/")
+load_dialog.set_filename(config.datadir + "levels/")
save_dialog = FileDialog("Save SuperTux Level as...", "Save", "Cancel",
gui.get_component())
-save_dialog.set_filename(supertux_datadir + "levels/")
+save_dialog.set_filename(config.datadir + "levels/")
gui.run()
Modified: trunk/src/minimap.cxx
===================================================================
--- trunk/src/minimap.cxx 2004-05-30 19:21:30 UTC (rev 371)
+++ trunk/src/minimap.cxx 2004-05-31 09:57:12 UTC (rev 372)
@@ -72,7 +72,7 @@
impl->editor_map = impl->parent->get_workspace().get_map();
}
- if (0)
+ if (1)
{ // Draw background color
CL_Display::fill_rect(CL_Rect(CL_Point(0, 0),
CL_Size(get_width(),
Modified: trunk/src/supertux.py
===================================================================
--- trunk/src/supertux.py 2004-05-30 19:21:30 UTC (rev 371)
+++ trunk/src/supertux.py 2004-05-31 09:57:12 UTC (rev 372)
@@ -20,7 +20,33 @@
from flexlay import *
from sexpr import *
import time
+import ConfigParser
+import os
+class Config:
+ config = None
+ datadir = None
+ recent_files = []
+
+ def __init__(self):
+ self.config = ConfigParser.ConfigParser()
+
+ # Setting defaults
+ self.config.add_section("SuperTux")
+ self.config.set("SuperTux", "datadir",
"/home/ingo/cvs/supertux/supertux/data/")
+ self.config.set("SuperTux", "recent_files", [])
+
+ self.config.read(['supertux.cfg',
os.path.expanduser('~/.flexlay/supertux.cfg')])
+
+ self.datadir = self.config.get("SuperTux", "datadir")
+ self.recent_files = eval(self.config.get("SuperTux", "recent_files"))
+
+ def __del__(self):
+ self.config.set("SuperTux", "datadir", self.datadir)
+ self.config.set("SuperTux", "recent_files", self.recent_files)
+
+ self.config.write(open(os.path.expanduser('~/.flexlay/supertux.cfg'),
'w'))
+
def load_game_tiles(tileset, filename):
"Load game tiles from filename into tileset"
tree = sexpr_read_from_file(filename)
@@ -35,7 +61,7 @@
image = get_value_from_tree(['images', '_'], data,
"notile.png")
tileset.add_tile(id,
- Tile(supertux_datadir + 'images/tilesets/' +
image,
+ Tile(config.datadir + 'images/tilesets/' + image,
CL_Color(254, 254, 254, 254),
CL_Color(255, 0, 0, 128)))
@@ -78,6 +104,9 @@
(self.filename,) = params
tree = sexpr_read_from_file(self.filename)
+ if tree == None:
+ raise "Couldn't load level"
+
data = tree[1:]
self.name = get_value_from_tree(["name", "_"], data, "no name")
@@ -238,7 +267,7 @@
load_game_tiles(tileset,
"/home/ingo/cvs/supertux/supertux/data/images/tilesets/supertux.stgt")
return tileset
-supertux_datadir = "/home/ingo/cvs/supertux/supertux/data/"
+config = Config()
supertux_tileset = load_supertux_tiles()
### End: 'Main Loop'
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Windstille-devel] rev 372 - trunk/src,
Ingo Ruhnke <=