Link Here
|
16 |
import texture2d; |
16 |
import texture2d; |
17 |
|
17 |
|
18 |
import std.stream; |
18 |
import std.stream; |
|
|
19 |
import std.c.stdlib; |
20 |
import std.string; |
19 |
|
21 |
|
20 |
import std.stdio; |
22 |
import std.stdio; |
21 |
|
23 |
|
22 |
class MenueLVL : MenueImpl { |
24 |
class MenueLVL : MenueImpl { |
23 |
public: |
25 |
public: |
|
|
26 |
|
27 |
static const char[] PREF_FILE = ".atomorun2008/savegame"; |
28 |
|
29 |
public char[] pref_file() { |
30 |
char * home = getenv("HOME"); |
31 |
if (home is null) |
32 |
throw new Error("HOME environment variable is not defined"); |
33 |
return std.string.toString(home) ~ "/" ~ PREF_FILE; |
34 |
} |
35 |
|
24 |
override void init(Menue theMenue) { |
36 |
override void init(Menue theMenue) { |
25 |
myButtons.length = 1; |
37 |
myButtons.length = 1; |
26 |
myButtons[0] = new Button; |
38 |
myButtons[0] = new Button; |
27 |
myButtons[0].init(Point2D(Config["window_width"]-250, 120), Point2D(256,37), ".main menu", "resources/sounds/menue_click.wav", "resources/sounds/menue_over.wav"); |
39 |
myButtons[0].init(Point2D(Config["window_width"]-250, 120), Point2D(256,37), ".main menu", "/usr/share/games/atomorun2008/resources/sounds/menue_click.wav", "/usr/share/games/atomorun2008/resources/sounds/menue_over.wav"); |
28 |
myButtons[0].addActionListener(theMenue, "Menue", "Main"); |
40 |
myButtons[0].addActionListener(theMenue, "Menue", "Main"); |
29 |
|
41 |
|
30 |
myImageButtons.length = 7; |
42 |
myImageButtons.length = 7; |
31 |
myImageButtons[0] = new ImageButton(); |
43 |
myImageButtons[0] = new ImageButton(); |
32 |
myImageButtons[0].init(Point2D(50, Config["window_height"]-250), Point2D(128,128),"Level 1", "resources/textures/lvls/lvl1_thumb.png", "resources/sounds/menue_click.wav", "resources/sounds/menue_over.wav"); |
44 |
myImageButtons[0].init(Point2D(50, Config["window_height"]-250), Point2D(128,128),"Level 1", "/usr/share/games/atomorun2008/resources/textures/lvls/lvl1_thumb.png", "/usr/share/games/atomorun2008/resources/sounds/menue_click.wav", "/usr/share/games/atomorun2008/resources/sounds/menue_over.wav"); |
33 |
myImageButtons[0].addActionListener(theMenue, "Game", "resources/lvls/lvl1.txt"); |
45 |
myImageButtons[0].addActionListener(theMenue, "Game", "/usr/share/games/atomorun2008/resources/lvls/lvl1.txt"); |
34 |
|
46 |
|
35 |
myImageButtons[1] = new ImageButton(); |
47 |
myImageButtons[1] = new ImageButton(); |
36 |
myImageButtons[1].init(Point2D(250, Config["window_height"]-250), Point2D(128,128),"Level 2", "resources/textures/lvls/lvl2_thumb.png", "resources/sounds/menue_click.wav", "resources/sounds/menue_over.wav"); |
48 |
myImageButtons[1].init(Point2D(250, Config["window_height"]-250), Point2D(128,128),"Level 2", "/usr/share/games/atomorun2008/resources/textures/lvls/lvl2_thumb.png", "/usr/share/games/atomorun2008/resources/sounds/menue_click.wav", "/usr/share/games/atomorun2008/resources/sounds/menue_over.wav"); |
37 |
myImageButtons[1].addActionListener(theMenue, "Game", "resources/lvls/lvl2.txt"); |
49 |
myImageButtons[1].addActionListener(theMenue, "Game", "/usr/share/games/atomorun2008/resources/lvls/lvl2.txt"); |
38 |
|
50 |
|
39 |
myImageButtons[2] = new ImageButton(); |
51 |
myImageButtons[2] = new ImageButton(); |
40 |
myImageButtons[2].init(Point2D(450, Config["window_height"]-250), Point2D(128,128),"Level 3", "resources/textures/lvls/lvl3_thumb.png", "resources/sounds/menue_click.wav", "resources/sounds/menue_over.wav"); |
52 |
myImageButtons[2].init(Point2D(450, Config["window_height"]-250), Point2D(128,128),"Level 3", "/usr/share/games/atomorun2008/resources/textures/lvls/lvl3_thumb.png", "/usr/share/games/atomorun2008/resources/sounds/menue_click.wav", "/usr/share/games/atomorun2008/resources/sounds/menue_over.wav"); |
41 |
myImageButtons[2].addActionListener(theMenue, "Game", "resources/lvls/lvl3.txt"); |
53 |
myImageButtons[2].addActionListener(theMenue, "Game", "/usr/share/games/atomorun2008/resources/lvls/lvl3.txt"); |
42 |
|
54 |
|
43 |
myImageButtons[3] = new ImageButton(); |
55 |
myImageButtons[3] = new ImageButton(); |
44 |
myImageButtons[3].init(Point2D(250, Config["window_height"]-650), Point2D(128,128),"Special Level", "resources/textures/lvls/lvl4_thumb.png", "resources/sounds/menue_click.wav", "resources/sounds/menue_over.wav"); |
56 |
myImageButtons[3].init(Point2D(250, Config["window_height"]-650), Point2D(128,128),"Special Level", "/usr/share/games/atomorun2008/resources/textures/lvls/lvl4_thumb.png", "/usr/share/games/atomorun2008/resources/sounds/menue_click.wav", "/usr/share/games/atomorun2008/resources/sounds/menue_over.wav"); |
45 |
myImageButtons[3].addActionListener(theMenue, "Game", "resources/lvls/lvlSpecial.txt"); |
57 |
myImageButtons[3].addActionListener(theMenue, "Game", "/usr/share/games/atomorun2008/resources/lvls/lvlSpecial.txt"); |
46 |
|
58 |
|
47 |
myImageButtons[4] = new ImageButton(); |
59 |
myImageButtons[4] = new ImageButton(); |
48 |
myImageButtons[4].init(Point2D(50, Config["window_height"]-450), Point2D(128,128),"Level 4", "resources/textures/lvls/lvl5_thumb.png", "resources/sounds/menue_click.wav", "resources/sounds/menue_over.wav"); |
60 |
myImageButtons[4].init(Point2D(50, Config["window_height"]-450), Point2D(128,128),"Level 4", "/usr/share/games/atomorun2008/resources/textures/lvls/lvl5_thumb.png", "/usr/share/games/atomorun2008/resources/sounds/menue_click.wav", "/usr/share/games/atomorun2008/resources/sounds/menue_over.wav"); |
49 |
myImageButtons[4].addActionListener(theMenue, "Game", "resources/lvls/lvl1b.txt"); |
61 |
myImageButtons[4].addActionListener(theMenue, "Game", "/usr/share/games/atomorun2008/resources/lvls/lvl1b.txt"); |
50 |
|
62 |
|
51 |
myImageButtons[5] = new ImageButton(); |
63 |
myImageButtons[5] = new ImageButton(); |
52 |
myImageButtons[5].init(Point2D(250, Config["window_height"]-450), Point2D(128,128),"Level 5", "resources/textures/lvls/lvl6_thumb.png", "resources/sounds/menue_click.wav", "resources/sounds/menue_over.wav"); |
64 |
myImageButtons[5].init(Point2D(250, Config["window_height"]-450), Point2D(128,128),"Level 5", "/usr/share/games/atomorun2008/resources/textures/lvls/lvl6_thumb.png", "/usr/share/games/atomorun2008/resources/sounds/menue_click.wav", "/usr/share/games/atomorun2008/resources/sounds/menue_over.wav"); |
53 |
myImageButtons[5].addActionListener(theMenue, "Game", "resources/lvls/lvl2b.txt"); |
65 |
myImageButtons[5].addActionListener(theMenue, "Game", "/usr/share/games/atomorun2008/resources/lvls/lvl2b.txt"); |
54 |
|
66 |
|
55 |
myImageButtons[6] = new ImageButton(); |
67 |
myImageButtons[6] = new ImageButton(); |
56 |
myImageButtons[6].init(Point2D(450, Config["window_height"]-450), Point2D(128,128),"Level 6", "resources/textures/lvls/lvl7_thumb.png", "resources/sounds/menue_click.wav", "resources/sounds/menue_over.wav"); |
68 |
myImageButtons[6].init(Point2D(450, Config["window_height"]-450), Point2D(128,128),"Level 6", "/usr/share/games/atomorun2008/resources/textures/lvls/lvl7_thumb.png", "/usr/share/games/atomorun2008/resources/sounds/menue_click.wav", "/usr/share/games/atomorun2008/resources/sounds/menue_over.wav"); |
57 |
myImageButtons[6].addActionListener(theMenue, "Game", "resources/lvls/lvl3b.txt"); |
69 |
myImageButtons[6].addActionListener(theMenue, "Game", "/usr/share/games/atomorun2008/resources/lvls/lvl3b.txt"); |
58 |
|
70 |
|
59 |
File hm = new File(); |
71 |
File hm = new File(); |
60 |
hm.open("resources/savegame", FileMode.In); |
72 |
hm.open(pref_file(), FileMode.In); |
61 |
int data; |
73 |
int data; |
62 |
while (!hm.eof) { |
74 |
while (!hm.eof) { |
63 |
hm.readf(&data); |
75 |
hm.readf(&data); |
Link Here
|
65 |
}; |
77 |
}; |
66 |
hm.close(); |
78 |
hm.close(); |
67 |
|
79 |
|
68 |
myTexGold = cast(Texture2D)ResourceManager.getInstance().need((Texture2D.classinfo), "resources/textures/prize/gold.png"); |
80 |
myTexGold = cast(Texture2D)ResourceManager.getInstance().need((Texture2D.classinfo), "/usr/share/games/atomorun2008/resources/textures/prize/gold.png"); |
69 |
myTexSilver = cast(Texture2D)ResourceManager.getInstance().need((Texture2D.classinfo), "resources/textures/prize/silver.png"); |
81 |
myTexSilver = cast(Texture2D)ResourceManager.getInstance().need((Texture2D.classinfo), "/usr/share/games/atomorun2008/resources/textures/prize/silver.png"); |
70 |
myTexBronze = cast(Texture2D)ResourceManager.getInstance().need((Texture2D.classinfo), "resources/textures/prize/bronze.png"); |
82 |
myTexBronze = cast(Texture2D)ResourceManager.getInstance().need((Texture2D.classinfo), "/usr/share/games/atomorun2008/resources/textures/prize/bronze.png"); |
71 |
}; |
83 |
}; |
72 |
override void refresh() { |
84 |
override void refresh() { |
73 |
foreach(button; myButtons) button.refresh(); |
85 |
foreach(button; myButtons) button.refresh(); |