Skip to content

Commit 7a4e815

Browse files
committed
Do a few things that I wanted to do before release
1 parent ecf3bae commit 7a4e815

9 files changed

Lines changed: 266 additions & 126 deletions

File tree

src/main/java/de/geolykt/starloader/api/empire/ActiveEmpire.java

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,10 @@ public interface ActiveEmpire extends Empire, Metadatable {
3737
* was cancelled.
3838
*
3939
* @param empireSpecial The registry key of the special.
40+
* @param force Whether to suppress the events that are fired otherwise
4041
* @return Whether the special was really removed.
4142
*/
42-
public boolean addSpecial(@NotNull NamespacedKey empireSpecial);
43+
public boolean addSpecial(@NotNull NamespacedKey empireSpecial, boolean force);
4344

4445
/**
4546
* Adds a callback that only applies to this empire.
@@ -55,11 +56,13 @@ public interface ActiveEmpire extends Empire, Metadatable {
5556
* Depending on the parameters the player can be notified about the event and the event may be included in the
5657
* bulletin ticker. This method does not allow to go lower that 1 for a good cause,
5758
* as this produces other severe issues like divide by 0.
59+
* Even if the events are suppressed a transcend event will be fired if the threshold for that has been reached.
5860
*
5961
* @param notify False if the action should happen silently, true if it is done in a more natural manner
62+
* @param force Whether to suppress the events that are fired otherwise
6063
* @return False if the event got cancelled or if the technology level is at 1
6164
*/
62-
public boolean decreaseTechnologyLevel(boolean notify);
65+
public boolean decreaseTechnologyLevel(boolean notify, boolean force);
6366

6467
/**
6568
* Obtains the {@link Vector} of the {@link StateActor StateActors} that are currently assigned to the empire.
@@ -153,11 +156,13 @@ public interface ActiveEmpire extends Empire, Metadatable {
153156
* have been cancelled or not.
154157
* Depending on the parameters the player can be notified about the event and the event may be included in the
155158
* bulletin ticker.
159+
* Even if the events are suppressed a transcend event will be fired if the threshold for that has been reached.
156160
*
157161
* @param notify False if the action should happen silently, true if it is done in a more natural manner
162+
* @param force Whether to suppress the events that are fired otherwise
158163
* @return False if the event got cancelled
159164
*/
160-
public boolean increaseTechnologyLevel(boolean notify);
165+
public boolean increaseTechnologyLevel(boolean notify, boolean force);
161166

162167
/**
163168
* Unassign a {@link StateActor} from the empire
@@ -174,9 +179,10 @@ public interface ActiveEmpire extends Empire, Metadatable {
174179
* was cancelled.
175180
*
176181
* @param empireSpecial The registry key of the special.
182+
* @param force Whether to suppress the events that are fired otherwise
177183
* @return Whether the special was really removed.
178184
*/
179-
public boolean removeSpecial(@NotNull NamespacedKey empireSpecial);
185+
public boolean removeSpecial(@NotNull NamespacedKey empireSpecial, boolean force);
180186

181187
/**
182188
* Sets the motto of the empire. The motto of an empire is purely for the user

src/main/java/de/geolykt/starloader/api/gui/Drawing.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ public static float drawText(@NotNull String message, float x, float y, @NotNull
112112
*
113113
* @param message The message to send
114114
*/
115-
public static void sendBulletin(@NotNull String message) { // FIXME typo
115+
public static void sendBulletin(@NotNull String message) {
116116
implementation.sendBulletin(message);
117117
}
118118

@@ -121,7 +121,7 @@ public static void sendBulletin(@NotNull String message) { // FIXME typo
121121
*
122122
* @param text The formatted text to send as a bulletin
123123
*/
124-
public static void sendBulltin(@NotNull FormattedText text) {
124+
public static void sendBulletin(@NotNull FormattedText text) {
125125
implementation.sendBulletin(text);
126126
}
127127

src/main/java/de/geolykt/starloader/api/gui/text/TextFactory.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,26 @@ public interface TextFactory {
2929

3030
/**
3131
* Creates a {@link FormattedText} based on a String. The default color is used.
32+
* It uses the small font size, where as {@link #asDefaultFormattedText(String)} uses the "default" monotype font.
33+
* The reason for this interesting naming decision is that normal bulletins make use of the small monotype font,
34+
* where as some of the empire-specific bulletins make use of the "default" one.
3235
*
3336
* @param text The text to encode
3437
* @return The text as a {@link FormattedText}
3538
*/
3639
public @NotNull FormattedText asFormattedText(@NotNull String text);
3740

41+
/**
42+
* Creates a {@link FormattedText} based on a String. The default color is used.
43+
* It uses the default font size, where as {@link #asFormattedText(String)} uses the small monotype font.
44+
* The reason for this interesting naming decision is that normal bulletins make use of the small monotype font,
45+
* where as some of the empire-specific bulletins make use of the "default" one.
46+
*
47+
* @param text The text to encode
48+
* @return The text as a {@link FormattedText}
49+
*/
50+
public @NotNull FormattedText asDefaultFormattedText(@NotNull String text);
51+
3852
/**
3953
* Creates a {@link FormattedText} based on a String. The specified color is used.
4054
*

src/main/java/de/geolykt/starloader/api/resource/AudioSampleWrapper.java

Lines changed: 50 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -4,38 +4,52 @@
44

55
import com.badlogic.gdx.audio.Sound;
66

7-
import snoddasmannen.galimulator.AudioManager$AudioSample;
7+
/**
8+
* Wrapper for sounds. They can be used to enrich the user experience, however this does not meant that the game is limited to
9+
* this selection of sounds, as extensions can implement their own sounds. Due to the relative simplicity of such actions,
10+
* the Starloader API does not (yet) provide a harmony or registry API for this and extensions need to work out their own
11+
* systems to do these actions.
12+
*/
13+
public abstract class AudioSampleWrapper implements ResourceWrapper<Sound> {
814

9-
public final class AudioSampleWrapper implements ResourceWrapper<Sound> { // TODO maybe we can use the AudioSample directly, but how would an IDE react to this?
15+
public static AudioSampleWrapper ACTOR_ORDERED = null;
1016

17+
public static AudioSampleWrapper ACTOR_SELECTED = null;
18+
19+
public static AudioSampleWrapper ALARM = null;
20+
public static AudioSampleWrapper BAD_MINI = null;
21+
public static AudioSampleWrapper BIG_LASER = null;
22+
public static AudioSampleWrapper BIGBOOM_1 = null;
23+
public static AudioSampleWrapper BIGBOOM_2 = null;
24+
public static AudioSampleWrapper CLONE = null;
25+
public static AudioSampleWrapper GOOD_MINI = null;
26+
public static AudioSampleWrapper HEALRAY = null;
27+
public static AudioSampleWrapper HIT_1 = null;
28+
public static AudioSampleWrapper HIT_2 = null;
29+
public static AudioSampleWrapper HIT_3 = null;
30+
public static AudioSampleWrapper MISSILE = null;
31+
public static AudioSampleWrapper SMALL_LASER = null;
32+
public static AudioSampleWrapper UI_BIG_SELECT = null;
33+
public static AudioSampleWrapper UI_ERROR = null;
34+
public static AudioSampleWrapper UI_SMALL_SELECT = null;
35+
/**
36+
* The location of the resource within the respective data folder.
37+
*/
1138
private final String location;
12-
private final AudioManager$AudioSample sample;
39+
/**
40+
* The sound resource that should be used
41+
*/
1342
private final Sound sound;
1443

15-
// This is madness
16-
public static final AudioSampleWrapper ACTOR_SELECTED = new AudioSampleWrapper("uismallselect.wav", AudioManager$AudioSample.a);
17-
public static final AudioSampleWrapper ACTOR_ORDERED = new AudioSampleWrapper("actoraction.wav", AudioManager$AudioSample.b);
18-
public static final AudioSampleWrapper GOOD_MINI = new AudioSampleWrapper("goodmini.wav", AudioManager$AudioSample.c);
19-
public static final AudioSampleWrapper BAD_MINI = new AudioSampleWrapper("badmini.wav", AudioManager$AudioSample.d);
20-
public static final AudioSampleWrapper UI_SMALL_SELECT = new AudioSampleWrapper("uismallselect.wav", AudioManager$AudioSample.e);
21-
public static final AudioSampleWrapper UI_BIG_SELECT = new AudioSampleWrapper("uiselect.wav", AudioManager$AudioSample.f);
22-
public static final AudioSampleWrapper UI_ERROR = new AudioSampleWrapper("error.wav", AudioManager$AudioSample.g);
23-
public static final AudioSampleWrapper BIG_LASER = new AudioSampleWrapper("biglaser.wav", AudioManager$AudioSample.h);
24-
public static final AudioSampleWrapper SMALL_LASER = new AudioSampleWrapper("biglaser.wav", AudioManager$AudioSample.i);
25-
public static final AudioSampleWrapper HIT_1 = new AudioSampleWrapper("smallhit1.wav", AudioManager$AudioSample.j);
26-
public static final AudioSampleWrapper HIT_2 = new AudioSampleWrapper("smallhit2.wav", AudioManager$AudioSample.k);
27-
public static final AudioSampleWrapper HIT_3 = new AudioSampleWrapper("smallhit3.wav", AudioManager$AudioSample.l);
28-
public static final AudioSampleWrapper ALARM = new AudioSampleWrapper("alarm.wav", AudioManager$AudioSample.m);
29-
public static final AudioSampleWrapper BIGBOOM_1 = new AudioSampleWrapper("bigboom1.wav", AudioManager$AudioSample.n);
30-
public static final AudioSampleWrapper BIGBOOM_2 = new AudioSampleWrapper("bigboom2.wav", AudioManager$AudioSample.o);
31-
public static final AudioSampleWrapper HEALRAY = new AudioSampleWrapper("healray.wav", AudioManager$AudioSample.p);
32-
public static final AudioSampleWrapper CLONE = new AudioSampleWrapper("clone.wav", AudioManager$AudioSample.q);
33-
public static final AudioSampleWrapper MISSILE = new AudioSampleWrapper("missile.wav", AudioManager$AudioSample.r);
34-
35-
private AudioSampleWrapper(String loc, AudioManager$AudioSample sample) {
44+
/**
45+
* Constructor.
46+
*
47+
* @param loc The location of the resource, should be formatted like a file name
48+
* @param sample The sound sample of the instance
49+
*/
50+
protected AudioSampleWrapper(String loc, Sound sample) {
3651
this.location = loc;
37-
this.sample = sample;
38-
this.sound = sample.sound; // FIXME DOES NOT WORK!
52+
this.sound = sample;
3953
}
4054

4155
@Override
@@ -48,11 +62,15 @@ private AudioSampleWrapper(String loc, AudioManager$AudioSample sample) {
4862
return sound;
4963
}
5064

51-
public void play() {
52-
sample.a();
53-
}
65+
/**
66+
* Plays the sample.
67+
*/
68+
public abstract void play();
5469

55-
public void play(float volume) {
56-
sample.a(volume);
57-
}
70+
/**
71+
* Plays the sample at a strictly defined volume. Note that 1.0 is not always the default, however it often is.
72+
*
73+
* @param volume The volume of the sound, should range between 0.0 and 1.0
74+
*/
75+
public abstract void play(float volume);
5876
}

src/main/java/de/geolykt/starloader/api/resource/ResourceWrapper.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
* Indicates the something is wrapping a resource.
77
* Due to the nature of the game most often they are enums,
88
* which makes modification with them more limited than with other things.
9+
* While for some enums they can be altered into a registry, for some other enums (most notably resources)
10+
* there are no need to do this step and wrapping it would be easier, like here.
911
*
1012
* @param <T> The object type that is wrapped by this resource wrapper
1113
*/

0 commit comments

Comments
 (0)