1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
|
package ch.asynk.tankontank.screens;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Screen;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.scenes.scene2d.Stage;
import com.badlogic.gdx.utils.viewport.FitViewport;
import com.badlogic.gdx.scenes.scene2d.ui.Skin;
import com.badlogic.gdx.scenes.scene2d.ui.Label;
import com.badlogic.gdx.scenes.scene2d.ui.CheckBox;
import com.badlogic.gdx.scenes.scene2d.ui.TextButton;
import com.badlogic.gdx.scenes.scene2d.ui.List;
import com.badlogic.gdx.scenes.scene2d.InputEvent;
import com.badlogic.gdx.scenes.scene2d.InputListener;
import ch.asynk.tankontank.TankOnTank;
import ch.asynk.tankontank.game.Battle;
class MyList extends List<Battle>
{
public MyList(Skin skin, Battle... items)
{
super(skin);
setItems(items);
layout();
setSize(getPrefWidth(), getPrefHeight());
}
}
public class OptionsScreen implements Screen
{
private final TankOnTank game;
private Stage stage;
private Label title1;
private TextButton okButton;
private CheckBox showMovesCk;
private CheckBox showTargetsCk;
private CheckBox showMoveAssistsCk;
private CheckBox canCancelCk;
private CheckBox mustValidateCk;
private CheckBox showEnemyPossibilitiesCk;
private CheckBox debugCk;
private Label title2;
private List<Battle> scenarios;
public OptionsScreen(final TankOnTank game)
{
this.game = game;
}
@Override
public void render(float delta)
{
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
stage.act();
stage.draw();
}
private void apply()
{
game.config.showMoves = showMovesCk.isChecked();
game.config.showTargets = showTargetsCk.isChecked();
game.config.showMoveAssists = showMoveAssistsCk.isChecked();
game.config.canCancel = canCancelCk.isChecked();
game.config.mustValidate = mustValidateCk.isChecked();
game.config.showEnemyPossibilities = showEnemyPossibilitiesCk.isChecked();
game.config.debug = debugCk.isChecked();
game.config.battle = scenarios.getSelected();
}
@Override
public void show()
{
TankOnTank.debug("OptionsScreen", "show()");
stage = new Stage(new FitViewport(Gdx.graphics.getWidth(), Gdx.graphics.getHeight()));
Gdx.input.setInputProcessor(stage);
title1 = new Label("Options", game.skin);
okButton = new TextButton("OK", game.skin);
showMovesCk = new CheckBox("Show Moves", game.skin);
showTargetsCk = new CheckBox("Show Targets", game.skin);
showMoveAssistsCk = new CheckBox("Show Moves Assists", game.skin);
canCancelCk = new CheckBox("Can Cancel", game.skin);
mustValidateCk = new CheckBox("Must Validate", game.skin);
showEnemyPossibilitiesCk = new CheckBox("Show Enemy Possibilities", game.skin);
debugCk = new CheckBox("Debug", game.skin);
title2 = new Label("Scenarios", game.skin);
scenarios = new MyList(game.skin, game.factory.battles);
showMovesCk.setChecked(game.config.showMoves);
showTargetsCk.setChecked(game.config.showTargets);
showMoveAssistsCk.setChecked(game.config.showMoveAssists);
canCancelCk.setChecked(game.config.canCancel);
mustValidateCk.setChecked(game.config.mustValidate);
showEnemyPossibilitiesCk.setChecked(game.config.showEnemyPossibilities);
debugCk.setChecked(game.config.debug);
okButton.addListener(new InputListener() {
public boolean touchDown (InputEvent event, float x, float y, int pointer, int button) {
return true;
}
public void touchUp (InputEvent event, float x, float y, int pointer, int button) {
apply();
game.setScreen(new GameScreen(game));
}
});
stage.addActor(title1);
stage.addActor(showMovesCk);
stage.addActor(showTargetsCk);
stage.addActor(showMoveAssistsCk);
stage.addActor(canCancelCk);
stage.addActor(mustValidateCk);
stage.addActor(showEnemyPossibilitiesCk);
stage.addActor(debugCk);
stage.addActor(okButton);
stage.addActor(title2);
stage.addActor(scenarios);
}
@Override
public void resize(int width, int height)
{
// TankOnTank.debug("OptionsScreen", "resize (" + width + "," + height + ")");
stage.getViewport().update(width, height, true);
float x = ((width / 2) - 100f);
float y = (height - 100f);
title1.setPosition((x - 20f), y);
y -= 20f;
showMovesCk.setPosition(x, y);
y -= 20f;
showTargetsCk.setPosition(x, y);
y -= 20f;
showMoveAssistsCk.setPosition(x, y);
y -= 20f;
canCancelCk.setPosition(x, y);
y -= 20f;
mustValidateCk.setPosition(x, y);
y -= 20f;
showEnemyPossibilitiesCk.setPosition(x, y);
y -= 20f;
debugCk.setPosition(x, y);
y -= 40f;
title2.setPosition((x - 20f), y);
y -= scenarios.getHeight();
scenarios.setPosition(x, y);
y -= 20f;
x += 200f;
okButton.setPosition(x, y);
}
@Override
public void dispose()
{
// TankOnTank.debug("LoadScreen", "dispose()");
stage.dispose();
}
@Override
public void hide()
{
// TankOnTank.debug("LoadScreen", "hide()");
}
@Override
public void pause()
{
// TankOnTank.debug("LoadScreen", "pause()");
}
@Override
public void resume()
{
// TankOnTank.debug("LoadScreen", "resume()");
}
}
|