Compare commits
201 commits
Author | SHA1 | Date | |
---|---|---|---|
9930d1bb6d | |||
38d29ba9c8 | |||
89e5775632 | |||
a9770ecea1 | |||
f579eee88b | |||
f7bb1b0fe7 | |||
d45a1a8c4a | |||
9e5ca9dd95 | |||
6afc26e601 | |||
256721aa12 | |||
431d54f779 | |||
d0984b143b | |||
2281e55a09 | |||
d566db0fc5 | |||
fcc5e9b640 | |||
339a7679f7 | |||
ad930fcbdc | |||
cdf8db1b50 | |||
8f1fda3f3d | |||
85028fd82a | |||
1128aa34ab | |||
e3edb3be8a | |||
06517a0d34 | |||
53a4f5f1a8 | |||
58163db658 | |||
17bb2e57ab | |||
836094a00b | |||
48918f0139 | |||
6d9522c80d | |||
83f66723c9 | |||
47021f9e49 | |||
1dea7e9645 | |||
678f37e184 | |||
9eb5f2cfd3 | |||
fa94de734b | |||
22fa5734a3 | |||
1258c07c1b | |||
46c73c8c46 | |||
8c414d53e3 | |||
7c2ce73de5 | |||
6114da126a | |||
cd7a739c5d | |||
98cf245b8d | |||
166064f21a | |||
4a6da6d0f7 | |||
1ae189c238 | |||
618a076c0f | |||
bda91dac26 | |||
ee3bf79c4c | |||
141c1b1f5c | |||
81613186e5 | |||
126ce64a24 | |||
367e6f5bfd | |||
c201df68b2 | |||
669fc77eab | |||
821a46b720 | |||
493230c4a6 | |||
5534531416 | |||
374e0c4617 | |||
f4c024cde7 | |||
35277daca8 | |||
6562d18dc1 | |||
663ef31db9 | |||
a6c2695ccb | |||
06a14ae645 | |||
228eec0a79 | |||
ec0a1aa5c3 | |||
1b61f085e3 | |||
d1a0847303 | |||
8e0bbd06c2 | |||
f30141c8f3 | |||
c8e5c16e41 | |||
18be47866c | |||
b14e539464 | |||
be0ab15153 | |||
f3117767fd | |||
414dc668ff | |||
b317139c97 | |||
3d0cc9665a | |||
18f37874fa | |||
902c795ecc | |||
5a394749bf | |||
bdf67a89f7 | |||
252c157cf0 | |||
b01b602728 | |||
815c52e5d7 | |||
b52053f5ea | |||
f76d3c8b89 | |||
6c55d59f1f | |||
753b4b8b5d | |||
c527989ada | |||
8be702b3aa | |||
688d5710c7 | |||
47a69ce8bc | |||
4433d3b3df | |||
dda5ac3573 | |||
17aad1f023 | |||
ad4949af16 | |||
2cee1d6632 | |||
435e3f3e29 | |||
5f49d6c036 | |||
4e51e18bdc | |||
bb6ebb0be8 | |||
fafcf0e0ab | |||
adc81d56d2 | |||
f879b060e8 | |||
ed02e53122 | |||
72df57fb3d | |||
6af3fd71e5 | |||
d8be274083 | |||
0b2ad9f92d | |||
e66758cd73 | |||
c0369d14b8 | |||
1d0dfddf25 | |||
a62dc2309d | |||
93d997c3c0 | |||
09149c7b88 | |||
f1219070d2 | |||
8fed598b51 | |||
e2ec9f0c84 | |||
20abca12f2 | |||
63c2a18c3a | |||
bb64949927 | |||
77b5a34a33 | |||
10fdaf0b1a | |||
2bc84f0c66 | |||
64b256c713 | |||
4a84f9e096 | |||
2cf7f0036d | |||
d41ad4db01 | |||
7299ab8e5c | |||
7fd8879c73 | |||
8bd9370bab | |||
aa0ff6cf96 | |||
d6d934f1f3 | |||
bd4b8d427a | |||
1eefb197f0 | |||
ffca1f62e5 | |||
88c43d0824 | |||
71e50743fd | |||
7126ca5a9f | |||
0055cbf806 | |||
41fae1317f | |||
f6b2fdf422 | |||
688522c5ca | |||
272392c8ea | |||
dfa5026a29 | |||
2dd83c61dc | |||
5e2b36dc82 | |||
26c71df542 | |||
7b6cff41c5 | |||
c62e3386aa | |||
7fd8a49d5c | |||
![]() |
4d1d323c72 | ||
![]() |
caef42dc16 | ||
![]() |
3a5a29cf9e | ||
![]() |
e6d16405c5 | ||
![]() |
31dd9d6303 | ||
![]() |
e145675525 | ||
![]() |
7c80936c05 | ||
![]() |
a7fe2db49f | ||
![]() |
89d2c8f6e4 | ||
![]() |
9a6c41661b | ||
![]() |
5066ddf9af | ||
![]() |
5b6bb3f10d | ||
![]() |
5b2a51a8b5 | ||
![]() |
8d4b4b3619 | ||
![]() |
2ea3267e3a | ||
![]() |
9077451c08 | ||
![]() |
e4034898b9 | ||
![]() |
660199b1d8 | ||
![]() |
10ba39c70b | ||
![]() |
eba8f6ea98 | ||
![]() |
111226fe28 | ||
![]() |
e26938ee77 | ||
![]() |
6d1e00ddef | ||
![]() |
a3e8566ca2 | ||
![]() |
6e77090c5b | ||
![]() |
66e9f68eee | ||
![]() |
1578d22e46 | ||
![]() |
95b5d0e3e3 | ||
![]() |
f89724e2aa | ||
![]() |
d8e54d4d69 | ||
![]() |
541b9cc461 | ||
![]() |
2158a700f4 | ||
![]() |
ad828ec6b4 | ||
![]() |
02c0bfcbf6 | ||
![]() |
6e5c9e842e | ||
![]() |
f1a13835a6 | ||
![]() |
49996f8116 | ||
![]() |
812a981e4a | ||
![]() |
193a12b00f | ||
![]() |
6b7923cf41 | ||
![]() |
6cab25e79f | ||
![]() |
278fd0b7e2 | ||
![]() |
d08d0e11fc | ||
![]() |
3e70accb76 | ||
![]() |
a6b0f110b1 | ||
![]() |
d37bb7f6cc | ||
![]() |
b17efb5b07 | ||
![]() |
2fa521c3d1 |
3269 changed files with 84196 additions and 43926 deletions
12
.gitattributes
vendored
Normal file
12
.gitattributes
vendored
Normal file
|
@ -0,0 +1,12 @@
|
|||
#
|
||||
# https://help.github.com/articles/dealing-with-line-endings/
|
||||
#
|
||||
# Linux start script should use lf
|
||||
/gradlew text eol=lf
|
||||
|
||||
# These are Windows script files and should use crlf
|
||||
*.bat text eol=crlf
|
||||
|
||||
# Binary files should be left untouched
|
||||
*.jar binary
|
||||
|
13
.gitignore
vendored
13
.gitignore
vendored
|
@ -1,5 +1,8 @@
|
|||
/java/run
|
||||
/java/bin
|
||||
/java/dev
|
||||
/export
|
||||
/.metadata
|
||||
/dev
|
||||
.metadata
|
||||
.classpath
|
||||
.project
|
||||
.settings
|
||||
.gradle
|
||||
bin
|
||||
build
|
||||
|
|
|
@ -1,3 +1,8 @@
|
|||
# TCR
|
||||
# TCR - That Cube Rocks
|
||||
|
||||
Ein Minecraft®™ 1.8.9 "Fork"
|
||||
Ein Block-basiertes Open-World-Spiel mit vielen Dimensionen und RPG-Elementen.
|
||||
|
||||
**Projekt ist in der frühen Entwicklungsphase / Alpha**
|
||||
|
||||
Dieses Projekt ist Public Domain, siehe UNLICENSE.
|
||||
Der Client verwendet LWJGL für GLFW und OpenGL, für dessen Lizenz siehe [Die LWJGL Website](https://www.lwjgl.org/license).
|
||||
|
|
47
client/build.gradle.kts
Normal file
47
client/build.gradle.kts
Normal file
|
@ -0,0 +1,47 @@
|
|||
|
||||
plugins {
|
||||
application
|
||||
id("com.gradleup.shadow") version "8.3.6"
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation(project(":common"))
|
||||
|
||||
implementation(platform("org.lwjgl:lwjgl-bom:3.3.6"))
|
||||
|
||||
implementation("org.lwjgl", "lwjgl")
|
||||
implementation("org.lwjgl", "lwjgl-glfw")
|
||||
implementation("org.lwjgl", "lwjgl-opengl")
|
||||
|
||||
runtimeOnly("org.lwjgl", "lwjgl", classifier = "natives-linux")
|
||||
runtimeOnly("org.lwjgl", "lwjgl", classifier = "natives-freebsd")
|
||||
runtimeOnly("org.lwjgl", "lwjgl", classifier = "natives-windows")
|
||||
runtimeOnly("org.lwjgl", "lwjgl-glfw", classifier = "natives-linux")
|
||||
runtimeOnly("org.lwjgl", "lwjgl-glfw", classifier = "natives-freebsd")
|
||||
runtimeOnly("org.lwjgl", "lwjgl-glfw", classifier = "natives-windows")
|
||||
runtimeOnly("org.lwjgl", "lwjgl-opengl", classifier = "natives-linux")
|
||||
runtimeOnly("org.lwjgl", "lwjgl-opengl", classifier = "natives-freebsd")
|
||||
runtimeOnly("org.lwjgl", "lwjgl-opengl", classifier = "natives-windows")
|
||||
}
|
||||
|
||||
java {
|
||||
toolchain {
|
||||
languageVersion = JavaLanguageVersion.of(21)
|
||||
}
|
||||
}
|
||||
|
||||
application {
|
||||
mainClass = "client.Client"
|
||||
tasks.run.get().workingDir = rootProject.file("dev/client")
|
||||
tasks.run.get().workingDir.mkdirs()
|
||||
tasks.run.get().systemProperties.put("runtime.devmode", "")
|
||||
}
|
||||
|
||||
tasks.shadowJar {
|
||||
destinationDirectory = rootProject.file("dev")
|
||||
archiveFileName = "tcr_client.jar"
|
||||
}
|
File diff suppressed because it is too large
Load diff
|
@ -1,4 +1,4 @@
|
|||
package game.audio;
|
||||
package client.audio;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
@ -7,13 +7,12 @@ import javax.sound.sampled.AudioFormat;
|
|||
import javax.sound.sampled.AudioFormat.Encoding;
|
||||
import javax.sound.sampled.AudioSystem;
|
||||
import javax.sound.sampled.DataLine.Info;
|
||||
import javax.sound.sampled.LineUnavailableException;
|
||||
|
||||
import common.collect.Lists;
|
||||
import common.log.Log;
|
||||
|
||||
import javax.sound.sampled.SourceDataLine;
|
||||
|
||||
import game.collect.Lists;
|
||||
|
||||
import game.log.Log;
|
||||
|
||||
public class AudioInterface implements Runnable {
|
||||
private static class Channel {
|
||||
short[] buffer;
|
||||
|
@ -138,12 +137,12 @@ public class AudioInterface implements Runnable {
|
|||
|
||||
public void run() {
|
||||
AudioFormat format = new AudioFormat(Encoding.PCM_SIGNED, 48000, 16, 2, 2 * 2, 48000, false);
|
||||
Info info = new Info(SourceDataLine.class, format, this.devbufsize);
|
||||
Info info = new Info(SourceDataLine.class, format, this.devbufsize == 0 ? AudioSystem.NOT_SPECIFIED : this.devbufsize);
|
||||
try {
|
||||
this.line = (SourceDataLine)AudioSystem.getLine(info);
|
||||
this.line.open(format, this.devbufsize);
|
||||
this.line.open(format, this.devbufsize == 0 ? AudioSystem.NOT_SPECIFIED : this.devbufsize);
|
||||
}
|
||||
catch(LineUnavailableException e) {
|
||||
catch(Exception e) {
|
||||
this.line = null;
|
||||
Log.SOUND.error(e, "Konnte Audiogerät nicht öffnen");
|
||||
}
|
|
@ -1,15 +1,16 @@
|
|||
package game.audio;
|
||||
package client.audio;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import game.audio.jogg.Packet;
|
||||
import game.audio.jogg.Page;
|
||||
import game.audio.jogg.StreamState;
|
||||
import game.audio.jogg.SyncState;
|
||||
import game.audio.jorbis.Block;
|
||||
import game.audio.jorbis.Comment;
|
||||
import game.audio.jorbis.DspState;
|
||||
import game.audio.jorbis.Info;
|
||||
|
||||
import client.audio.jogg.Packet;
|
||||
import client.audio.jogg.Page;
|
||||
import client.audio.jogg.StreamState;
|
||||
import client.audio.jogg.SyncState;
|
||||
import client.audio.jorbis.Block;
|
||||
import client.audio.jorbis.Comment;
|
||||
import client.audio.jorbis.DspState;
|
||||
import client.audio.jorbis.Info;
|
||||
|
||||
public class CodecJOrbis
|
||||
{
|
|
@ -1,19 +1,28 @@
|
|||
package game.audio;
|
||||
package client.audio;
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import game.collect.BiMap;
|
||||
import game.collect.HashBiMap;
|
||||
import game.collect.Lists;
|
||||
import game.collect.Maps;
|
||||
|
||||
import game.Game;
|
||||
import game.entity.npc.EntityNPC;
|
||||
import game.util.ExtMath;
|
||||
import client.Client;
|
||||
import client.util.FileUtils;
|
||||
import common.collect.BiMap;
|
||||
import common.collect.HashBiMap;
|
||||
import common.collect.Lists;
|
||||
import common.collect.Maps;
|
||||
import common.entity.npc.EntityNPC;
|
||||
import common.init.SoundEvent;
|
||||
import common.log.Log;
|
||||
import common.rng.Random;
|
||||
import common.sound.MovingSound;
|
||||
import common.sound.Sound;
|
||||
import common.util.ExtMath;
|
||||
|
||||
public class SoundManager {
|
||||
private class Source {
|
||||
|
@ -67,13 +76,16 @@ public class SoundManager {
|
|||
}
|
||||
}
|
||||
|
||||
private static final Random RANDOM = new Random();
|
||||
private static final Map<SoundEvent, short[][]> BUFFERS = Maps.newEnumMap(SoundEvent.class);
|
||||
|
||||
private final Map<String, Sound> playingSounds = HashBiMap.<String, Sound>create();
|
||||
private final Map<Sound, String> invPlayingSounds = ((BiMap)this.playingSounds).inverse();
|
||||
private final List<MovingSound> tickableSounds = Lists.<MovingSound>newArrayList();
|
||||
private final Map<String, Integer> playingSoundsStopTime = Maps.<String, Integer>newHashMap();
|
||||
private final Map<String, Source> sources = new HashMap<String, Source>();
|
||||
private final String[] channels = new String[28];
|
||||
private final Game gm;
|
||||
private final Client gm;
|
||||
|
||||
private float listenerX;
|
||||
private float listenerY;
|
||||
|
@ -82,10 +94,50 @@ public class SoundManager {
|
|||
private int playTime = 0;
|
||||
private int eventId = 0;
|
||||
|
||||
public SoundManager(Game gm) {
|
||||
public SoundManager(Client gm) {
|
||||
this.gm = gm;
|
||||
}
|
||||
|
||||
public static void loadSounds() {
|
||||
for(SoundEvent entry : SoundEvent.values()) {
|
||||
short[][] buffers = new short[entry.getSounds().length][];
|
||||
for(int z = 0; z < entry.getSounds().length; z++) {
|
||||
String sound = entry.getSounds()[z];
|
||||
Log.SOUND.trace("Lade Sound %s", sound);
|
||||
buffers[z] = readOgg("sounds/" + sound + ".ogg");
|
||||
}
|
||||
BUFFERS.put(entry, buffers);
|
||||
}
|
||||
}
|
||||
|
||||
private static short[] readOgg(String filename) {
|
||||
InputStream in = null;
|
||||
try {
|
||||
in = new BufferedInputStream(FileUtils.getResource(filename));
|
||||
return CodecJOrbis.readAll(in);
|
||||
}
|
||||
catch(FileNotFoundException e) {
|
||||
Log.IO.error("Fehler beim Lesen von OPUS-Datei '%s': Datei nicht gefunden", filename);
|
||||
return null;
|
||||
}
|
||||
catch(Exception e) {
|
||||
Log.IO.error("Fehler beim Lesen von OPUS-Datei '%s': %s", filename, e.getMessage());
|
||||
return null;
|
||||
}
|
||||
finally {
|
||||
try {
|
||||
if(in != null)
|
||||
in.close();
|
||||
}
|
||||
catch(IOException e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static short[] getBuffer(SoundEvent event) {
|
||||
return RANDOM.pick(BUFFERS.get(event));
|
||||
}
|
||||
|
||||
public void unload()
|
||||
{
|
||||
this.stopSounds();
|
||||
|
@ -183,11 +235,11 @@ public class SoundManager {
|
|||
if (volume > 0.0F)
|
||||
{
|
||||
String s = String.format("snd-%016x", this.eventId++);
|
||||
this.sources.put(s, new Source(sound.getSoundLocation().getBuffer(), sound.getChannelType(), sound.canRepeat(), s, sound.getXPosF(), sound.getYPosF(), sound.getZPosF(), sound.getAttenuationType(), attn, volume));
|
||||
this.sources.put(s, new Source(getBuffer(sound.getSoundLocation()), Volume.getByType(sound.getChannelType()), sound.canRepeat(), s, sound.getXPosF(), sound.getYPosF(), sound.getZPosF(), sound.getAttenuationType(), attn, volume));
|
||||
this.playingSoundsStopTime.put(s, this.playTime + 20);
|
||||
this.playingSounds.put(s, sound);
|
||||
if (sound instanceof MovingSound)
|
||||
this.tickableSounds.add((MovingSound)sound);
|
||||
if (sound instanceof MovingSound moving)
|
||||
this.tickableSounds.add(moving);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,25 +1,46 @@
|
|||
package game.audio;
|
||||
package client.audio;
|
||||
|
||||
import game.Game;
|
||||
import game.color.TextColor;
|
||||
import game.gui.element.Slider;
|
||||
import game.vars.CVar;
|
||||
import game.vars.CVarCategory;
|
||||
import client.Client;
|
||||
import client.gui.element.Slider;
|
||||
import client.gui.element.SliderCallback;
|
||||
import client.vars.CVar;
|
||||
import client.vars.CVarCategory;
|
||||
import common.color.TextColor;
|
||||
import common.sound.EventType;
|
||||
|
||||
public enum Volume implements CVar {
|
||||
MASTER("master", "Gesamt"),
|
||||
MUSIC("music", "Musik"),
|
||||
SFX("sfx", "Geräusche"),
|
||||
GUI("gui", "Oberfläche");
|
||||
SFX("sfx", "Geräusche", EventType.SOUND_EFFECT),
|
||||
GUI("gui", "Oberfläche", EventType.UI_INTERFACE);
|
||||
|
||||
private static final Volume[] LOOKUP = new Volume[EventType.values().length];
|
||||
|
||||
public final String id;
|
||||
public final String name;
|
||||
public final EventType type;
|
||||
|
||||
private int value = 100;
|
||||
|
||||
private Volume(String id, String name) {
|
||||
private Volume(String id, String name, EventType type) {
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
private Volume(String id, String name) {
|
||||
this(id, name, null);
|
||||
}
|
||||
|
||||
static {
|
||||
for(Volume volume : values()) {
|
||||
if(volume.type != null)
|
||||
LOOKUP[volume.type.ordinal()] = volume;
|
||||
}
|
||||
}
|
||||
|
||||
public static Volume getByType(EventType type) {
|
||||
return LOOKUP[type.ordinal()];
|
||||
}
|
||||
|
||||
public String getDisplay() {
|
||||
|
@ -71,12 +92,12 @@ public enum Volume implements CVar {
|
|||
}
|
||||
|
||||
public void apply() {
|
||||
if(Game.getGame().getAudioInterface() != null)
|
||||
Game.getGame().getAudioInterface().alSetVolume(this, (short)(((float)this.value) / 100.0f * 32767.0f));
|
||||
if(Client.CLIENT.getAudioInterface() != null)
|
||||
Client.CLIENT.getAudioInterface().alSetVolume(this, (short)(((float)this.value) / 100.0f * 32767.0f));
|
||||
}
|
||||
|
||||
public Slider selector(int x, int y, int w, int h) {
|
||||
return new Slider(x, y, w, h, 0, 0, 100, 100, this.value, new Slider.Callback() {
|
||||
return new Slider(x, y, w, h, 0, 0, 100, 100, this.value, new SliderCallback() {
|
||||
public void use(Slider elem, int value) {
|
||||
Volume.this.value = value;
|
||||
Volume.this.apply();
|
|
@ -24,7 +24,7 @@
|
|||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
package game.audio.jogg;
|
||||
package client.audio.jogg;
|
||||
|
||||
public class Buffer{
|
||||
private static final int BUFFER_INCREMENT=256;
|
|
@ -24,7 +24,7 @@
|
|||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
package game.audio.jogg;
|
||||
package client.audio.jogg;
|
||||
|
||||
public class Packet{
|
||||
public byte[] packet_base;
|
|
@ -24,7 +24,7 @@
|
|||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
package game.audio.jogg;
|
||||
package client.audio.jogg;
|
||||
|
||||
public class Page{
|
||||
private static int[] crc_lookup=new int[256];
|
|
@ -24,7 +24,7 @@
|
|||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
package game.audio.jogg;
|
||||
package client.audio.jogg;
|
||||
|
||||
public class StreamState{
|
||||
byte[] body_data; /* bytes from packet bodies */
|
|
@ -24,7 +24,7 @@
|
|||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
package game.audio.jogg;
|
||||
package client.audio.jogg;
|
||||
|
||||
// DECODING PRIMITIVES: packet streaming layer
|
||||
|
|
@ -24,9 +24,10 @@
|
|||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
package game.audio.jorbis;
|
||||
package client.audio.jorbis;
|
||||
|
||||
import game.audio.jogg.*;
|
||||
import client.audio.jogg.Buffer;
|
||||
import client.audio.jogg.Packet;
|
||||
|
||||
public class Block{
|
||||
///necessary stream state for linking to the framing abstraction
|
|
@ -24,7 +24,7 @@
|
|||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
package game.audio.jorbis;
|
||||
package client.audio.jorbis;
|
||||
|
||||
class ChainingExample{
|
||||
public static void main(String[] arg){
|
|
@ -24,9 +24,9 @@
|
|||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
package game.audio.jorbis;
|
||||
package client.audio.jorbis;
|
||||
|
||||
import game.audio.jogg.*;
|
||||
import client.audio.jogg.Buffer;
|
||||
|
||||
class CodeBook{
|
||||
int dim; // codebook dimensions (elements per vector)
|
|
@ -24,9 +24,10 @@
|
|||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
package game.audio.jorbis;
|
||||
package client.audio.jorbis;
|
||||
|
||||
import game.audio.jogg.*;
|
||||
import client.audio.jogg.Buffer;
|
||||
import client.audio.jogg.Packet;
|
||||
|
||||
// the comments are not part of vorbis_info so that vorbis_info can be
|
||||
// static storage
|
|
@ -24,9 +24,12 @@
|
|||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
package game.audio.jorbis;
|
||||
package client.audio.jorbis;
|
||||
|
||||
import game.audio.jogg.*;
|
||||
import client.audio.jogg.Packet;
|
||||
import client.audio.jogg.Page;
|
||||
import client.audio.jogg.StreamState;
|
||||
import client.audio.jogg.SyncState;
|
||||
|
||||
// Takes a vorbis bitstream from stdin and writes raw stereo PCM to
|
||||
// stdout. Decodes simple and chained OggVorbis files from beginning
|
|
@ -24,7 +24,7 @@
|
|||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
package game.audio.jorbis;
|
||||
package client.audio.jorbis;
|
||||
|
||||
class Drft{
|
||||
int n;
|
|
@ -24,7 +24,7 @@
|
|||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
package game.audio.jorbis;
|
||||
package client.audio.jorbis;
|
||||
|
||||
public class DspState{
|
||||
static final float M_PI=3.1415926539f;
|
|
@ -24,9 +24,9 @@
|
|||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
package game.audio.jorbis;
|
||||
package client.audio.jorbis;
|
||||
|
||||
import game.audio.jogg.*;
|
||||
import client.audio.jogg.Buffer;
|
||||
|
||||
class Floor0 extends FuncFloor{
|
||||
|
|
@ -24,9 +24,9 @@
|
|||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
package game.audio.jorbis;
|
||||
package client.audio.jorbis;
|
||||
|
||||
import game.audio.jogg.*;
|
||||
import client.audio.jogg.Buffer;
|
||||
|
||||
class Floor1 extends FuncFloor{
|
||||
static final int floor1_rangedb=140;
|
|
@ -24,9 +24,9 @@
|
|||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
package game.audio.jorbis;
|
||||
package client.audio.jorbis;
|
||||
|
||||
import game.audio.jogg.*;
|
||||
import client.audio.jogg.Buffer;
|
||||
|
||||
abstract class FuncFloor{
|
||||
|
|
@ -24,9 +24,9 @@
|
|||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
package game.audio.jorbis;
|
||||
package client.audio.jorbis;
|
||||
|
||||
import game.audio.jogg.*;
|
||||
import client.audio.jogg.Buffer;
|
||||
|
||||
abstract class FuncMapping{
|
||||
public static FuncMapping[] mapping_P= {new Mapping0()};
|
|
@ -24,9 +24,9 @@
|
|||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
package game.audio.jorbis;
|
||||
package client.audio.jorbis;
|
||||
|
||||
import game.audio.jogg.*;
|
||||
import client.audio.jogg.Buffer;
|
||||
|
||||
abstract class FuncResidue{
|
||||
public static FuncResidue[] residue_P= {new Residue0(), new Residue1(),
|
|
@ -24,9 +24,9 @@
|
|||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
package game.audio.jorbis;
|
||||
package client.audio.jorbis;
|
||||
|
||||
import game.audio.jogg.*;
|
||||
import client.audio.jogg.Buffer;
|
||||
|
||||
abstract class FuncTime{
|
||||
public static FuncTime[] time_P= {new Time0()};
|
|
@ -24,9 +24,10 @@
|
|||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
package game.audio.jorbis;
|
||||
package client.audio.jorbis;
|
||||
|
||||
import game.audio.jogg.*;
|
||||
import client.audio.jogg.Buffer;
|
||||
import client.audio.jogg.Packet;
|
||||
|
||||
public class Info{
|
||||
private static final int OV_EBADPACKET=-136;
|
|
@ -24,7 +24,7 @@
|
|||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
package game.audio.jorbis;
|
||||
package client.audio.jorbis;
|
||||
|
||||
class InfoMode{
|
||||
int blockflag;
|
|
@ -24,7 +24,7 @@
|
|||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
package game.audio.jorbis;
|
||||
package client.audio.jorbis;
|
||||
|
||||
public class JOrbisException extends Exception{
|
||||
|
|
@ -24,7 +24,7 @@
|
|||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
package game.audio.jorbis;
|
||||
package client.audio.jorbis;
|
||||
|
||||
class Lookup{
|
||||
static final int COS_LOOKUP_SZ=128;
|
|
@ -24,7 +24,7 @@
|
|||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
package game.audio.jorbis;
|
||||
package client.audio.jorbis;
|
||||
|
||||
class Lpc{
|
||||
// en/decode lookups
|
|
@ -24,7 +24,7 @@
|
|||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
package game.audio.jorbis;
|
||||
package client.audio.jorbis;
|
||||
|
||||
/*
|
||||
function: LSP (also called LSF) conversion routines
|
|
@ -24,9 +24,9 @@
|
|||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
package game.audio.jorbis;
|
||||
package client.audio.jorbis;
|
||||
|
||||
import game.audio.jogg.*;
|
||||
import client.audio.jogg.Buffer;
|
||||
|
||||
class Mapping0 extends FuncMapping{
|
||||
static int seq=0;
|
|
@ -24,7 +24,7 @@
|
|||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
package game.audio.jorbis;
|
||||
package client.audio.jorbis;
|
||||
|
||||
class Mdct{
|
||||
|
|
@ -24,7 +24,7 @@
|
|||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
package game.audio.jorbis;
|
||||
package client.audio.jorbis;
|
||||
|
||||
// psychoacoustic setup
|
||||
class PsyInfo{
|
|
@ -24,7 +24,7 @@
|
|||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
package game.audio.jorbis;
|
||||
package client.audio.jorbis;
|
||||
|
||||
class PsyLook{
|
||||
int n;
|
|
@ -24,9 +24,9 @@
|
|||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
package game.audio.jorbis;
|
||||
package client.audio.jorbis;
|
||||
|
||||
import game.audio.jogg.*;
|
||||
import client.audio.jogg.Buffer;
|
||||
|
||||
class Residue0 extends FuncResidue{
|
||||
void pack(Object vr, Buffer opb){
|
|
@ -24,7 +24,7 @@
|
|||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
package game.audio.jorbis;
|
||||
package client.audio.jorbis;
|
||||
|
||||
class Residue1 extends Residue0{
|
||||
|
|
@ -24,7 +24,7 @@
|
|||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
package game.audio.jorbis;
|
||||
package client.audio.jorbis;
|
||||
|
||||
class Residue2 extends Residue0{
|
||||
|
|
@ -24,9 +24,9 @@
|
|||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
package game.audio.jorbis;
|
||||
package client.audio.jorbis;
|
||||
|
||||
import game.audio.jogg.*;
|
||||
import client.audio.jogg.Buffer;
|
||||
|
||||
class StaticCodeBook{
|
||||
int dim; // codebook dimensions (elements per vector)
|
|
@ -24,9 +24,9 @@
|
|||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
package game.audio.jorbis;
|
||||
package client.audio.jorbis;
|
||||
|
||||
import game.audio.jogg.*;
|
||||
import client.audio.jogg.Buffer;
|
||||
|
||||
class Time0 extends FuncTime{
|
||||
void pack(Object i, Buffer opb){
|
|
@ -1,4 +1,4 @@
|
|||
package game.audio.jorbis;
|
||||
package client.audio.jorbis;
|
||||
|
||||
class Util{
|
||||
static int ilog(int v){
|
|
@ -25,13 +25,15 @@
|
|||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
package game.audio.jorbis;
|
||||
|
||||
import java.io.InputStream;
|
||||
|
||||
import game.audio.jogg.*;
|
||||
package client.audio.jorbis;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
import client.audio.jogg.Packet;
|
||||
import client.audio.jogg.Page;
|
||||
import client.audio.jogg.StreamState;
|
||||
import client.audio.jogg.SyncState;
|
||||
|
||||
public class VorbisFile{
|
||||
static final int CHUNKSIZE=8500;
|
|
@ -1,4 +1,4 @@
|
|||
package game.util;
|
||||
package client.gui;
|
||||
|
||||
import java.io.File;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package game.gui;
|
||||
package client.gui;
|
||||
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.FileNotFoundException;
|
||||
|
@ -6,15 +6,16 @@ import java.io.IOException;
|
|||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import game.log.Log;
|
||||
import game.renderer.GlState;
|
||||
import game.renderer.texture.TextureUtil;
|
||||
import game.util.FileUtils;
|
||||
import client.renderer.GlState;
|
||||
import client.renderer.texture.TextureUtil;
|
||||
import client.util.FileUtils;
|
||||
import common.log.Log;
|
||||
|
||||
public class Font {
|
||||
public static final FontChar[] SIZES = new FontChar[256];
|
||||
public static final int XGLYPH = 12;
|
||||
public static final int YGLYPH = 18;
|
||||
|
||||
public static int XGLYPH = 12;
|
||||
public static int YGLYPH = 14;
|
||||
|
||||
private static int texture;
|
||||
|
||||
|
@ -72,10 +73,12 @@ public class Font {
|
|||
}
|
||||
}
|
||||
|
||||
public static void load() {
|
||||
public static void load(boolean tiny) {
|
||||
XGLYPH = tiny ? 6 : 12;
|
||||
YGLYPH = tiny ? 7 : 14;
|
||||
BufferedImage img = null;
|
||||
try {
|
||||
img = TextureUtil.readImage(FileUtils.getResource("textures/font.png"));
|
||||
img = TextureUtil.readImage(FileUtils.getResource("textures/font" + (tiny ? "_tiny" : "") + ".png"));
|
||||
}
|
||||
catch(FileNotFoundException e) {
|
||||
Log.IO.error("Konnte Font-Textur nicht laden: Datei nicht vorhanden");
|
|
@ -1,4 +1,4 @@
|
|||
package game.gui;
|
||||
package client.gui;
|
||||
|
||||
public class FontChar {
|
||||
public final byte s;
|
|
@ -1,6 +1,6 @@
|
|||
package game.util;
|
||||
package client.gui;
|
||||
|
||||
import game.gui.element.Element;
|
||||
import client.gui.element.Element;
|
||||
|
||||
public interface Formatter<T extends Element> {
|
||||
String use(T elem);
|
|
@ -1,27 +1,26 @@
|
|||
package game.gui;
|
||||
package client.gui;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.lwjgl.opengl.GL13;
|
||||
|
||||
import game.collect.Lists;
|
||||
|
||||
import game.Game;
|
||||
import game.gui.element.Dropdown;
|
||||
import game.gui.element.Dropdown.Handle;
|
||||
import game.gui.element.Element;
|
||||
import game.renderer.Drawing;
|
||||
import game.renderer.GlState;
|
||||
import game.window.Bind;
|
||||
import game.window.Button;
|
||||
import game.window.Keysym;
|
||||
import client.Client;
|
||||
import client.gui.element.Dropdown;
|
||||
import client.gui.element.Dropdown.Handle;
|
||||
import client.gui.element.Element;
|
||||
import client.renderer.Drawing;
|
||||
import client.renderer.GlState;
|
||||
import client.window.Bind;
|
||||
import client.window.Button;
|
||||
import client.window.Keysym;
|
||||
import common.collect.Lists;
|
||||
|
||||
public abstract class Gui {
|
||||
public static final String DIRT_BACKGROUND = "textures/background.png";
|
||||
public static final String BACKGROUND = "textures/background.png";
|
||||
public static final int HOVER_COLOR = 0x288080ff;
|
||||
public static final int PRESS_COLOR = 0x30afafff;
|
||||
|
||||
protected final Game gm = Game.getGame();
|
||||
protected final Client gm = Client.CLIENT;
|
||||
|
||||
public Element selected;
|
||||
private int min_x;
|
||||
|
@ -177,8 +176,8 @@ public abstract class Gui {
|
|||
this.min_y = Math.min(this.min_y, elem.getY());
|
||||
this.max_x = Math.max(this.max_x, elem.getX() + elem.getWidth());
|
||||
this.max_y = Math.max(this.max_y, elem.getY() + elem.getHeight());
|
||||
if(elem instanceof Dropdown)
|
||||
this.add(((Dropdown)elem).getHandle());
|
||||
if(elem instanceof Dropdown drop)
|
||||
this.add(drop.getHandle());
|
||||
return elem;
|
||||
}
|
||||
|
||||
|
@ -302,13 +301,13 @@ public abstract class Gui {
|
|||
// }
|
||||
|
||||
public void drawMainBackground() {
|
||||
if(this.gm.theWorld != null && !this.gm.charEditor) {
|
||||
if(this.gm.world != null && !this.gm.charEditor) {
|
||||
// Drawing.drawGradient(0, 0, this.fb_x, this.fb_y, this.theWorld == null ? this.style.bg_top : 0x3f202020,
|
||||
// this.theWorld == null ? this.style.bg_btm : 0x3f000000);
|
||||
Drawing.drawGradient(0, 0, this.gm.fb_x, this.gm.fb_y, 0xc0101010, 0xd0101010);
|
||||
}
|
||||
else {
|
||||
Drawing.drawScaled(this.gm, DIRT_BACKGROUND);
|
||||
Drawing.drawScaled(this.gm, BACKGROUND);
|
||||
}
|
||||
}
|
||||
|
46
client/src/main/java/client/gui/GuiConfirm.java
Executable file
46
client/src/main/java/client/gui/GuiConfirm.java
Executable file
|
@ -0,0 +1,46 @@
|
|||
package client.gui;
|
||||
|
||||
import client.gui.element.ActButton;
|
||||
import client.gui.element.ButtonCallback;
|
||||
import client.gui.element.Label;
|
||||
import client.gui.element.MultiLabel;
|
||||
import client.gui.element.PressType;
|
||||
|
||||
public class GuiConfirm extends Gui implements ButtonCallback {
|
||||
public static interface Callback {
|
||||
void confirm(boolean confirmed);
|
||||
}
|
||||
|
||||
private final Callback callback;
|
||||
private final String messageLine1;
|
||||
private final String messageLine2;
|
||||
private final String confirmButtonText;
|
||||
private final String cancelButtonText;
|
||||
|
||||
private ActButton confirmBtn;
|
||||
private ActButton cancelBtn;
|
||||
|
||||
public GuiConfirm(Callback callback, String msg1, String msg2, String msgConfirm, String msgCancel) {
|
||||
this.callback = callback;
|
||||
this.messageLine1 = msg1;
|
||||
this.messageLine2 = msg2;
|
||||
this.confirmButtonText = msgConfirm;
|
||||
this.cancelButtonText = msgCancel;
|
||||
}
|
||||
|
||||
public void init(int width, int height) {
|
||||
this.add(new Label(0, 0, 700, 0, this.messageLine1));
|
||||
this.add(new MultiLabel(0, 40, 700, 300, this.messageLine2, true));
|
||||
this.confirmBtn = this.add(new ActButton(100, 400, 245, 0, this, this.confirmButtonText));
|
||||
this.cancelBtn = this.add(new ActButton(355, 400, 245, 0, this, this.cancelButtonText));
|
||||
this.shift();
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return "Aktion bestätigen";
|
||||
}
|
||||
|
||||
public void use(ActButton btn, PressType mode) {
|
||||
this.callback.confirm(btn == this.confirmBtn);
|
||||
}
|
||||
}
|
379
client/src/main/java/client/gui/GuiConnect.java
Normal file
379
client/src/main/java/client/gui/GuiConnect.java
Normal file
|
@ -0,0 +1,379 @@
|
|||
package client.gui;
|
||||
|
||||
import java.io.File;
|
||||
import java.security.KeyPair;
|
||||
import java.security.PrivateKey;
|
||||
import java.security.PublicKey;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
|
||||
import client.gui.element.ActButton;
|
||||
import client.gui.element.ButtonCallback;
|
||||
import client.gui.element.GuiList;
|
||||
import client.gui.element.ListEntry;
|
||||
import client.gui.element.NavButton;
|
||||
import client.gui.element.PressType;
|
||||
import client.renderer.Drawing;
|
||||
import client.util.FileUtils;
|
||||
import common.color.TextColor;
|
||||
import common.log.Log;
|
||||
import common.network.IPlayer;
|
||||
import common.util.EncryptUtil;
|
||||
import common.util.Pair;
|
||||
import common.util.Util;
|
||||
|
||||
public class GuiConnect extends GuiList<GuiConnect.ServerInfo> implements ButtonCallback {
|
||||
public class ServerInfo implements Comparable<ServerInfo>, ListEntry {
|
||||
private final boolean direct;
|
||||
|
||||
private String name;
|
||||
private String address;
|
||||
private int port;
|
||||
private String user;
|
||||
private String password;
|
||||
private String access;
|
||||
private KeyPair keypair;
|
||||
private String keyDigest;
|
||||
private PublicKey serverKey;
|
||||
private String serverDigest;
|
||||
private boolean enforceEncryption;
|
||||
private long lastConnected;
|
||||
|
||||
public ServerInfo(String address, int port, String user, String password, String access) {
|
||||
this.direct = true;
|
||||
this.name = DIRECT_NAME;
|
||||
this.address = address;
|
||||
this.port = port;
|
||||
this.user = user;
|
||||
this.password = password;
|
||||
this.access = access;
|
||||
this.lastConnected = -1L;
|
||||
}
|
||||
|
||||
public ServerInfo(String name, String address, int port, String user, String password, String access, KeyPair keypair, long lastConnected, PublicKey serverKey, boolean enforceEnc) {
|
||||
this.direct = false;
|
||||
this.name = name;
|
||||
this.address = address;
|
||||
this.port = port;
|
||||
this.user = user;
|
||||
this.password = password;
|
||||
this.access = access;
|
||||
this.keypair = keypair;
|
||||
this.lastConnected = lastConnected;
|
||||
this.serverKey = serverKey;
|
||||
this.enforceEncryption = enforceEnc;
|
||||
if(this.keypair != null)
|
||||
this.keyDigest = EncryptUtil.getXorSha512Hash(this.keypair.getPublic().getEncoded());
|
||||
if(this.serverKey != null)
|
||||
this.serverDigest = EncryptUtil.getXorSha512Hash(this.serverKey.getEncoded());
|
||||
}
|
||||
|
||||
public boolean isDirect() {
|
||||
return this.direct;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public String getAddress() {
|
||||
return this.address;
|
||||
}
|
||||
|
||||
public int getPort() {
|
||||
return this.port;
|
||||
}
|
||||
|
||||
public String getUser() {
|
||||
return this.user;
|
||||
}
|
||||
|
||||
public String getPassword() {
|
||||
return this.password;
|
||||
}
|
||||
|
||||
public String getAccess() {
|
||||
return this.access;
|
||||
}
|
||||
|
||||
public KeyPair getKeypair() {
|
||||
return this.keypair;
|
||||
}
|
||||
|
||||
public PublicKey getServerKey() {
|
||||
return this.serverKey;
|
||||
}
|
||||
|
||||
public boolean requiresEncryption() {
|
||||
return this.enforceEncryption;
|
||||
}
|
||||
|
||||
public long getLastConnected() {
|
||||
return this.lastConnected;
|
||||
}
|
||||
|
||||
public void setData(String name, String address, int port, String user, String password, String access, KeyPair keypair, PublicKey serverKey, boolean encryptReq) {
|
||||
this.name = name;
|
||||
this.address = address;
|
||||
this.port = port;
|
||||
this.user = user;
|
||||
this.password = password;
|
||||
this.access = access;
|
||||
this.keypair = keypair;
|
||||
this.serverKey = serverKey;
|
||||
this.enforceEncryption = encryptReq;
|
||||
this.keyDigest = this.keypair != null ? EncryptUtil.getXorSha512Hash(this.keypair.getPublic().getEncoded()) : null;
|
||||
this.serverDigest = this.serverKey != null ? EncryptUtil.getXorSha512Hash(this.serverKey.getEncoded()) : null;
|
||||
}
|
||||
|
||||
public void setLastConnected() {
|
||||
this.lastConnected = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
public void setServerKey(PublicKey key) {
|
||||
this.serverKey = key;
|
||||
this.serverDigest = this.serverKey != null ? EncryptUtil.getXorSha512Hash(this.serverKey.getEncoded()) : null;
|
||||
}
|
||||
|
||||
public int compareTo(ServerInfo comp) {
|
||||
return this.lastConnected < comp.lastConnected ? 1 : (this.lastConnected > comp.lastConnected ? -1 : this.name.compareTo(comp.name));
|
||||
}
|
||||
|
||||
public void select(boolean isDoubleClick, int mouseX, int mouseY) {
|
||||
GuiConnect.this.selectButton.enabled = true;
|
||||
GuiConnect.this.deleteButton.enabled = true;
|
||||
GuiConnect.this.editButton.enabled = true;
|
||||
GuiConnect.this.copyButton.enabled = true;
|
||||
|
||||
if(isDoubleClick) {
|
||||
GuiConnect.this.use(GuiConnect.this.selectButton, PressType.PRIMARY);
|
||||
}
|
||||
}
|
||||
|
||||
public void draw(int x, int y, int width, int height, int mouseXIn, int mouseYIn, boolean hover) {
|
||||
Drawing.drawText(this.name + TextColor.GRAY + " - " + TextColor.RESET + this.user, x + 2, y, 0xffffffff);
|
||||
if(this.keypair != null || !this.password.isEmpty())
|
||||
Drawing.drawTextRight(
|
||||
(this.keypair != null ? "Pubkey " + this.keyDigest : "") + (this.keypair != null && !this.password.isEmpty() ? " + " : "") + (!this.password.isEmpty() ? "Passwort" : ""),
|
||||
x + width - 2, y, 0xffffffff);
|
||||
Drawing.drawText(this.address + TextColor.GRAY + " Port " + TextColor.RESET + this.port + (this.enforceEncryption ? TextColor.GRAY + ", nur verschlüsselt" : ""),
|
||||
x + 2, y + height - Font.YGLYPH * 2, 0xffb0b0b0);
|
||||
if(!this.access.isEmpty())
|
||||
Drawing.drawTextRight((this.keypair != null || !this.password.isEmpty() ? "+ " : "") + "Server-Passwort", x + width - 2, y + height - Font.YGLYPH * 2, 0xffb0b0b0);
|
||||
Drawing.drawText("Zuletzt verbunden: " + (this.lastConnected == -1L ? "nie" : DATE_FORMAT.format(new Date(this.lastConnected))), x + 2, y + height - Font.YGLYPH, 0xffb0b0b0);
|
||||
if(this.serverDigest != null)
|
||||
Drawing.drawTextRight("Server-ID: " + this.serverDigest, x + width - 2, y + height - Font.YGLYPH, 0xffb0b0b0);
|
||||
}
|
||||
}
|
||||
|
||||
public static final GuiConnect INSTANCE = new GuiConnect();
|
||||
private static final String DIRECT_NAME = "<Direktverbindung>";
|
||||
private static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("dd.MM.yyyy HH:mm:ss");
|
||||
private static final File SERVERS_FILE = new File("servers.cfg");
|
||||
|
||||
private ActButton deleteButton;
|
||||
private ActButton selectButton;
|
||||
private ActButton copyButton;
|
||||
private ActButton editButton;
|
||||
private ActButton createButton;
|
||||
|
||||
private GuiConnect() {
|
||||
}
|
||||
|
||||
public void init(int width, int height) {
|
||||
super.init(width, height);
|
||||
this.setDimensions(width, height, 32, height - 32);
|
||||
this.elements.clear();
|
||||
if(SERVERS_FILE.exists()) {
|
||||
try {
|
||||
String[] lines = FileUtils.read(SERVERS_FILE).split("\n");
|
||||
String name = "";
|
||||
String address = "";
|
||||
int port = -1;
|
||||
String user = "";
|
||||
String password = "";
|
||||
String access = "";
|
||||
byte[] key = null;
|
||||
byte[] pubkey = null;
|
||||
byte[] serverKey = null;
|
||||
boolean enforceEnc = false;
|
||||
long time = -1L;
|
||||
for(int z = 0; z <= lines.length; z++) {
|
||||
String line = z == lines.length ? null : lines[z];
|
||||
if(line == null || (line.startsWith("[") && line.endsWith("]"))) {
|
||||
if(!name.isEmpty() && !address.isEmpty() && !user.isEmpty() && user.length() < IPlayer.MAX_USER_LENGTH && IPlayer.isValidUser(user) &&
|
||||
password.length() < IPlayer.MAX_PASS_LENGTH && access.length() < IPlayer.MAX_PASS_LENGTH && address.length() < 128 && name.length() < 128 &&
|
||||
port >= 1024 && port <= 32767 && (password.length() >= 8 || password.isEmpty()) && (access.length() >= 8 || access.isEmpty()) && !this.isNameTaken(name)) {
|
||||
PrivateKey priv = key == null ? null : EncryptUtil.decodePrivateKey(key);
|
||||
PublicKey pub = pubkey == null ? null : EncryptUtil.decodePublicKey(pubkey);
|
||||
PublicKey serv = serverKey == null ? null : EncryptUtil.decodePublicKey(serverKey);
|
||||
this.elements.add(new ServerInfo(name, address, port, user, password, access, priv == null || pub == null ? null : new KeyPair(pub, priv), time, serv, enforceEnc));
|
||||
}
|
||||
if(line != null) {
|
||||
address = "";
|
||||
port = -1;
|
||||
user = "";
|
||||
password = "";
|
||||
access = "";
|
||||
key = null;
|
||||
pubkey = null;
|
||||
serverKey = null;
|
||||
enforceEnc = false;
|
||||
time = -1L;
|
||||
name = line.substring(1, line.length() - 1);
|
||||
}
|
||||
}
|
||||
else {
|
||||
Pair<String, String> value = Util.getKeyValue(line);
|
||||
if(value.first().equals("address"))
|
||||
address = value.second();
|
||||
else if(value.first().equals("port"))
|
||||
try {
|
||||
port = Integer.parseInt(value.second());
|
||||
}
|
||||
catch(NumberFormatException e) {
|
||||
}
|
||||
else if(value.first().equals("user"))
|
||||
user = value.second();
|
||||
else if(value.first().equals("password"))
|
||||
password = value.second();
|
||||
else if(value.first().equals("access"))
|
||||
access = value.second();
|
||||
else if(value.first().equals("connected"))
|
||||
try {
|
||||
time = Long.parseLong(value.second());
|
||||
}
|
||||
catch(NumberFormatException e) {
|
||||
}
|
||||
else if(value.first().equals("encryption_enforced"))
|
||||
enforceEnc = true;
|
||||
else if(value.first().equals("serverkey"))
|
||||
serverKey = Util.fromHexString(value.second());
|
||||
else if(value.first().equals("key"))
|
||||
key = Util.fromHexString(value.second());
|
||||
else if(value.first().equals("pubkey"))
|
||||
pubkey = Util.fromHexString(value.second());
|
||||
}
|
||||
}
|
||||
Collections.sort(this.elements);
|
||||
}
|
||||
catch(Exception e) {
|
||||
Log.IO.error("Konnte Serverliste nicht laden", e);
|
||||
this.elements.clear();
|
||||
}
|
||||
}
|
||||
|
||||
this.add(this.selectButton = new ActButton(width / 2 - 379, height - 30, 150, 0, this, "Verbinden"));
|
||||
this.add(this.createButton = new ActButton(width - 202, 12, 200, 0, this, "Server hinzufügen ..."));
|
||||
this.add(this.deleteButton = new ActButton(width / 2 - 75, height - 30, 150, 0, this, "Löschen"));
|
||||
this.add(this.editButton = new ActButton(width / 2 + 77, height - 30, 150, 0, this, "Bearbeiten"));
|
||||
this.add(this.copyButton = new ActButton(width / 2 - 227, height - 30, 150, 0, this, "Kopieren"));
|
||||
this.add(new NavButton(width / 2 + 229, height - 30, 150, 0, GuiMenu.INSTANCE, "Abbrechen"));
|
||||
|
||||
this.selectButton.enabled = false;
|
||||
this.deleteButton.enabled = false;
|
||||
this.editButton.enabled = false;
|
||||
this.copyButton.enabled = false;
|
||||
}
|
||||
|
||||
public void onGuiClosed() {
|
||||
this.save();
|
||||
}
|
||||
|
||||
public void applyServer(ServerInfo server) {
|
||||
if(this.selectedElement < 0)
|
||||
this.elements.add(server);
|
||||
this.save();
|
||||
this.gm.displayGuiScreen(this);
|
||||
}
|
||||
|
||||
public boolean isNameTaken(String name) {
|
||||
for(int z = 0; z < this.elements.size(); z++) {
|
||||
if(this.selectedElement != z && this.elements.get(z).getName().equals(name))
|
||||
return true;
|
||||
}
|
||||
return DIRECT_NAME.equals(name);
|
||||
}
|
||||
|
||||
public void editServer(ServerInfo server) {
|
||||
if(!server.isDirect())
|
||||
this.save();
|
||||
}
|
||||
|
||||
public void connect(String address, int port, String user, String pass, String access) {
|
||||
this.gm.connect(new ServerInfo(address, port, user, pass, access));
|
||||
}
|
||||
|
||||
private void save() {
|
||||
try {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for(ServerInfo server : this.elements) {
|
||||
if(sb.length() > 0)
|
||||
sb.append("\n");
|
||||
sb.append("[" + server.getName() + "]");
|
||||
sb.append("\naddress " + server.getAddress());
|
||||
sb.append("\nport " + server.getPort());
|
||||
sb.append("\nuser " + server.getUser());
|
||||
if(!server.getPassword().isEmpty())
|
||||
sb.append("\npassword " + server.getPassword());
|
||||
if(!server.getAccess().isEmpty())
|
||||
sb.append("\naccess " + server.getAccess());
|
||||
if(server.getKeypair() != null) {
|
||||
sb.append("\nkey " + Util.getHexString(server.getKeypair().getPrivate().getEncoded()));
|
||||
sb.append("\npubkey " + Util.getHexString(server.getKeypair().getPublic().getEncoded()));
|
||||
}
|
||||
if(server.requiresEncryption())
|
||||
sb.append("\nencryption_enforced");
|
||||
if(server.getLastConnected() != -1L)
|
||||
sb.append("\nconnected " + server.getLastConnected());
|
||||
if(server.getServerKey() != null)
|
||||
sb.append("\nserverkey " + Util.getHexString(server.getServerKey().getEncoded()));
|
||||
}
|
||||
FileUtils.write(SERVERS_FILE, sb.toString());
|
||||
}
|
||||
catch(Exception e) {
|
||||
Log.IO.error("Konnte Serverliste nicht speichern", e);
|
||||
}
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return "Server auswählen";
|
||||
}
|
||||
|
||||
public int getSlotHeight() {
|
||||
return 56;
|
||||
}
|
||||
|
||||
public void use(ActButton button, PressType mode) {
|
||||
if(button == this.deleteButton) {
|
||||
if(this.selectedElement >= 0) {
|
||||
this.elements.remove(this.selectedElement);
|
||||
this.gm.displayGuiScreen(this);
|
||||
}
|
||||
}
|
||||
else if(button == this.selectButton) {
|
||||
ServerInfo server = this.getSelected();
|
||||
if(server != null) {
|
||||
server.setLastConnected();
|
||||
this.gm.connect(server);
|
||||
}
|
||||
}
|
||||
else if(button == this.createButton) {
|
||||
this.setSelected(-1);
|
||||
this.gm.displayGuiScreen(new GuiServer(new ServerInfo("", "", -1, "", "", "", null, -1L, null, false)));
|
||||
}
|
||||
else if(button == this.editButton) {
|
||||
ServerInfo server = this.getSelected();
|
||||
if(server != null)
|
||||
this.gm.displayGuiScreen(new GuiServer(server));
|
||||
}
|
||||
else if(button == this.copyButton) {
|
||||
ServerInfo server = this.getSelected();
|
||||
if(server != null) {
|
||||
this.setSelected(-1);
|
||||
this.gm.displayGuiScreen(new GuiServer(new ServerInfo(server.name, server.address, server.port, server.user, server.password, server.access, server.keypair, -1L, null, server.enforceEncryption)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,26 +1,29 @@
|
|||
package game.gui;
|
||||
package client.gui;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import game.collect.Lists;
|
||||
import client.Client;
|
||||
import client.gui.element.ActButton;
|
||||
import client.gui.element.ButtonCallback;
|
||||
import client.gui.element.Element;
|
||||
import client.gui.element.Fill;
|
||||
import client.gui.element.PressType;
|
||||
import client.gui.element.FieldAction;
|
||||
import client.gui.element.Field;
|
||||
import client.gui.element.FieldCallback;
|
||||
import client.vars.BoolVar;
|
||||
import client.vars.CVar;
|
||||
import client.gui.element.TransparentArea;
|
||||
import client.window.Keysym;
|
||||
import common.collect.Lists;
|
||||
import common.color.TextColor;
|
||||
import common.network.IPlayer;
|
||||
import common.packet.CPacketComplete;
|
||||
import common.util.BlockPos;
|
||||
import common.util.ExtMath;
|
||||
import common.util.HitPosition;
|
||||
|
||||
import game.Game;
|
||||
import game.color.TextColor;
|
||||
import game.gui.element.ActButton;
|
||||
import game.gui.element.Fill;
|
||||
import game.gui.element.Textbox;
|
||||
import game.gui.element.Textbox.Action;
|
||||
import game.gui.element.TransparentBox;
|
||||
import game.network.Player;
|
||||
import game.packet.CPacketComplete;
|
||||
import game.util.ExtMath;
|
||||
import game.vars.BoolVar;
|
||||
import game.vars.CVar;
|
||||
import game.window.Keysym;
|
||||
import game.world.BlockPos;
|
||||
import game.world.HitPosition;
|
||||
|
||||
public class GuiConsole extends Gui implements Textbox.Callback {
|
||||
public class GuiConsole extends Gui implements FieldCallback {
|
||||
public static final GuiConsole INSTANCE = new GuiConsole();
|
||||
|
||||
private final List<String> sentMessages = Lists.<String>newArrayList();
|
||||
|
@ -35,8 +38,8 @@ public class GuiConsole extends Gui implements Textbox.Callback {
|
|||
private String prefixFirst;
|
||||
private int autocompleteIndex;
|
||||
private List<String> foundPlayerNames = Lists.<String>newArrayList();
|
||||
private Textbox inputField;
|
||||
private TransparentBox logBox;
|
||||
private Field inputField;
|
||||
private TransparentArea logBox;
|
||||
|
||||
public GuiConsole setFull(boolean full) {
|
||||
this.full = full;
|
||||
|
@ -45,20 +48,20 @@ public class GuiConsole extends Gui implements Textbox.Callback {
|
|||
|
||||
public void init(int width, int height) {
|
||||
if(this.full) {
|
||||
this.addSelector("con_autoclose", 0, 0, 160, 24);
|
||||
this.addSelector("con_timestamps", 160, 0, 160, 24);
|
||||
this.addSelector("con_loglevel", 320, 0, 160, 24);
|
||||
this.add(new ActButton(480, 0, 160, 24, new ActButton.Callback() {
|
||||
public void use(ActButton elem, ActButton.Mode action) {
|
||||
this.addSelector("con_autoclose", 0, 0, 160, 0);
|
||||
this.addSelector("con_timestamps", 160, 0, 160, 0);
|
||||
this.addSelector("con_loglevel", 320, 0, 160, 0);
|
||||
this.add(new ActButton(480, 0, 160, 0, new ButtonCallback() {
|
||||
public void use(ActButton elem, PressType action) {
|
||||
GuiConsole.this.reset();
|
||||
GuiConsole.this.setLog(GuiConsole.this.gm.getBuffer());
|
||||
}
|
||||
}, "Löschen"));
|
||||
}
|
||||
this.logBox = this.add(new TransparentBox(0, this.full ? 24 : 0, width, height - (this.full ? 48 : 24), this.gm.getBuffer(), this.gm.theWorld != null && !this.gm.charEditor));
|
||||
this.logBox = this.add(new TransparentArea(0, this.full ? Element.BASE_HEIGHT : 0, width, height - Element.BASE_HEIGHT * (this.full ? 2 : 1), this.gm.getBuffer(), this.gm.world != null && !this.gm.charEditor));
|
||||
if(this.full)
|
||||
this.add(new Fill(640, 0, width - 640, 24));
|
||||
this.inputField = this.add(new Textbox(0, height - 24, width, 24, Player.MAX_CMD_LENGTH, true, this, ""));
|
||||
this.add(new Fill(640, 0, width - 640, 0));
|
||||
this.inputField = this.add(new Field(0, height - Element.BASE_HEIGHT, width, 0, IPlayer.MAX_CMD_LENGTH, this, ""));
|
||||
this.inputField.setSelected();
|
||||
this.sentHistoryCursor = this.sentMessages.size();
|
||||
}
|
||||
|
@ -79,7 +82,7 @@ public class GuiConsole extends Gui implements Textbox.Callback {
|
|||
}
|
||||
|
||||
public void drawMainBackground() {
|
||||
if(this.gm.theWorld == null || this.gm.charEditor)
|
||||
if(this.gm.world == null || this.gm.charEditor)
|
||||
super.drawMainBackground();
|
||||
}
|
||||
|
||||
|
@ -90,13 +93,13 @@ public class GuiConsole extends Gui implements Textbox.Callback {
|
|||
this.playerNamesFound = false;
|
||||
}
|
||||
|
||||
public void use(Textbox elem, Action value)
|
||||
public void use(Field elem, FieldAction value)
|
||||
{
|
||||
this.waitingOnAutocomplete = false;
|
||||
|
||||
if (value == Action.FORWARD || value == Action.BACKWARD)
|
||||
if (value == FieldAction.FORWARD || value == FieldAction.BACKWARD)
|
||||
{
|
||||
this.reverse = value == Action.BACKWARD;
|
||||
this.reverse = value == FieldAction.BACKWARD;
|
||||
this.autocompletePlayerNames();
|
||||
}
|
||||
else
|
||||
|
@ -104,11 +107,11 @@ public class GuiConsole extends Gui implements Textbox.Callback {
|
|||
this.playerNamesFound = false;
|
||||
}
|
||||
|
||||
if(value == Action.PREVIOUS)
|
||||
if(value == FieldAction.PREVIOUS)
|
||||
this.getSentHistory(-1);
|
||||
else if (value == Action.NEXT)
|
||||
else if (value == FieldAction.NEXT)
|
||||
this.getSentHistory(1);
|
||||
if(value == Action.SEND)
|
||||
if(value == FieldAction.SEND)
|
||||
{
|
||||
String s = this.inputField.getText().trim();
|
||||
|
||||
|
@ -123,7 +126,7 @@ public class GuiConsole extends Gui implements Textbox.Callback {
|
|||
}
|
||||
|
||||
this.inputField.setText("");
|
||||
if((this.gm.conAutoclose || !this.full) && this.gm.theWorld != null)
|
||||
if((this.gm.conAutoclose || !this.full) && this.gm.world != null)
|
||||
this.gm.displayGuiScreen(null);
|
||||
}
|
||||
}
|
||||
|
@ -142,7 +145,7 @@ public class GuiConsole extends Gui implements Textbox.Callback {
|
|||
|
||||
private void addMessage(String msg) {
|
||||
String buffer = this.gm.getBuffer();
|
||||
if((buffer.length() + msg.length() + 2) > Game.LOG_BUFFER) {
|
||||
if((buffer.length() + msg.length() + 2) > Client.LOG_BUFFER) {
|
||||
int offset = (msg.length() + 2) > 1024 ? (msg.length() + 2) : 1024;
|
||||
int nl = buffer.indexOf('\n', offset);
|
||||
buffer = nl >= 0 ? buffer.substring(nl + 1) : "";
|
||||
|
@ -154,7 +157,7 @@ public class GuiConsole extends Gui implements Textbox.Callback {
|
|||
{
|
||||
if (this.playerNamesFound)
|
||||
{
|
||||
this.inputField.deleteFromCursor();
|
||||
this.inputField.deleteSpaceToCur();
|
||||
|
||||
if (this.autocompleteIndex >= this.foundPlayerNames.size())
|
||||
{
|
||||
|
@ -167,11 +170,11 @@ public class GuiConsole extends Gui implements Textbox.Callback {
|
|||
}
|
||||
else
|
||||
{
|
||||
int i = this.inputField.getNthCharFromPos();
|
||||
int i = this.inputField.getSpaceBeforeCur();
|
||||
this.foundPlayerNames.clear();
|
||||
this.autocompleteIndex = 0;
|
||||
// String s = this.inputField.getText().substring(i).toLowerCase();
|
||||
String s1 = this.inputField.getText().substring(0, this.inputField.getCursorPosition());
|
||||
String s1 = this.inputField.getText().substring(0, this.inputField.getCursorPos());
|
||||
String[] localMatches = this.sendAutocompleteRequest(s1);
|
||||
if(localMatches != null) {
|
||||
this.onAutocompleteResponse(localMatches);
|
||||
|
@ -184,7 +187,7 @@ public class GuiConsole extends Gui implements Textbox.Callback {
|
|||
}
|
||||
|
||||
this.playerNamesFound = true;
|
||||
this.inputField.deleteFromCursor();
|
||||
this.inputField.deleteSpaceToCur();
|
||||
}
|
||||
|
||||
if (this.foundPlayerNames.size() > 1)
|
||||
|
@ -215,7 +218,7 @@ public class GuiConsole extends Gui implements Textbox.Callback {
|
|||
s = argv[argv.length - 1];
|
||||
Iterable<String> res = pre.startsWith("#") ?
|
||||
(argv.length == 1 ? this.gm.getVars() : (argv.length == 2 ? getVarCompletion(argv[0].substring(1)) : Lists.newArrayList())) :
|
||||
(this.gm.thePlayer == null ? Lists.newArrayList() : this.gm.thePlayer.sendQueue.getPlayerNames());
|
||||
(this.gm.player == null ? Lists.newArrayList() : this.gm.playerList.keySet());
|
||||
if(argv.length == 1 && pre.startsWith("#"))
|
||||
s = s.substring(1);
|
||||
for(String s1 : res) {
|
||||
|
@ -252,10 +255,10 @@ public class GuiConsole extends Gui implements Textbox.Callback {
|
|||
blockpos = new BlockPos(this.gm.pointed.entity);
|
||||
}
|
||||
if(currentText.startsWith("/")) {
|
||||
if(this.gm.thePlayer != null) {
|
||||
if(this.gm.player != null) {
|
||||
currentText = currentText.substring(1);
|
||||
this.prefixFirst = currentText.split(" ", -1).length == 1 ? "/" : null;
|
||||
this.gm.thePlayer.sendQueue.addToSendQueue(new CPacketComplete(currentText, eid, blockpos));
|
||||
this.gm.player.client.addToSendQueue(new CPacketComplete(currentText, eid, blockpos));
|
||||
this.waitingOnAutocomplete = true;
|
||||
}
|
||||
}
|
||||
|
@ -314,12 +317,12 @@ public class GuiConsole extends Gui implements Textbox.Callback {
|
|||
}
|
||||
}
|
||||
|
||||
String s1 = this.inputField.getText().substring(this.inputField.getNthCharFromPos());
|
||||
String s1 = this.inputField.getText().substring(this.inputField.getSpaceBeforeCur());
|
||||
String s2 = getCommonPrefix(choices);
|
||||
|
||||
if (s2.length() > 0 && !s1.equalsIgnoreCase(s2))
|
||||
{
|
||||
this.inputField.deleteFromCursor();
|
||||
this.inputField.deleteSpaceToCur();
|
||||
this.inputField.insertText(s2);
|
||||
}
|
||||
else if (this.foundPlayerNames.size() > 0)
|
|
@ -1,32 +1,35 @@
|
|||
package game.gui;
|
||||
package client.gui;
|
||||
|
||||
import game.color.TextColor;
|
||||
import game.gui.element.NavButton;
|
||||
import game.gui.element.TransparentBox;
|
||||
import game.init.Config;
|
||||
import game.log.Log;
|
||||
import client.Client;
|
||||
import client.gui.element.MultiLabel;
|
||||
import client.gui.element.NavButton;
|
||||
import common.Version;
|
||||
import common.color.TextColor;
|
||||
import common.log.Log;
|
||||
import common.util.Util;
|
||||
|
||||
public class GuiInfo extends Gui {
|
||||
private static final String VER =
|
||||
TextColor.GREEN + "" + TextColor.BUG + "" + TextColor.BUG + "" + TextColor.BUG + " " + TextColor.VIOLET + "" + Config.VERSION + "" +
|
||||
TextColor.GREEN + " " + TextColor.BUG + "" + TextColor.BUG + "" + TextColor.BUG;
|
||||
TextColor.GREEN + "" + Util.repeatString(TextColor.BUG, Version.RELEASE.getId()) + TextColor.DVIOLET + "|-| " + TextColor.VIOLET + Client.VERSION + TextColor.DVIOLET + " |-|" +
|
||||
TextColor.GREEN + Util.repeatString(TextColor.BUG, Version.RELEASE.getId());
|
||||
|
||||
private static final String INFO = "Ein Spiel zur Simulation, zum Testen, für Rollenspiele, Mehrspieler und vieles mehr." + "\n" +
|
||||
"Optimiert für Geschwindigkeit, Stabilität und" + TextColor.UNKNOWN + "" + TextColor.UNKNOWN + " [Speicherzugriffsfehler]";
|
||||
private static final String HACKED = "Ein weiterer Release von WAAAAAAAAAAAAAAAAAAAAAAAAAAAAGHDRIVE!!!1!!!ONEoneOnetyone!1!!!" + "\n" +
|
||||
private static final String HACKED = "Ein weiterer Release von WAAAAAAAAAAAAGHDRIVE!!!1!!!ONEoneOnetyone!1!!!" + "\n" +
|
||||
"Update 0.2 - Läuft jetzt auch mit nur 512KB Fast-RAM!";
|
||||
|
||||
private static final String[] LIBRARIES = {
|
||||
"LWJGL 3.3.6+1 (GLFW + OpenGL)",
|
||||
"Netty 4.1.119-Final"
|
||||
"LWJGL 3.3.6",
|
||||
"LWJGL-GLFW 3.3.6",
|
||||
"LWJGL-OpenGL 3.3.6"
|
||||
};
|
||||
private static final String[] CODE = {
|
||||
"Albert Pham - WorldEdit (Snippets)",
|
||||
"Joonas Vali - NameGenerator",
|
||||
"LWJGL 2.9.4-nightly-20150209 - Project, Vector*, Matrix*",
|
||||
"Guava 17.0 - collect, future, Predicates",
|
||||
"JOrbis 20101023 (JCraft) - jogg, jorbis, CodecJOrbis",
|
||||
"MC 1.8.9"
|
||||
"Netty 4.0.23-Final - net.*",
|
||||
"JOrbis 20101023 (JCraft) - jogg, jorbis, CodecJOrbis"
|
||||
};
|
||||
|
||||
public static final GuiInfo INSTANCE = new GuiInfo("Über dieses Programm", getFormat(false));
|
||||
|
@ -36,12 +39,12 @@ public class GuiInfo extends Gui {
|
|||
private final String info;
|
||||
|
||||
private static String getFormat(boolean hax) {
|
||||
return getInfo(hax) + "\n\n" + getCredits(hax) + "\n\n" + getLibraries(hax) + "\n\n" + getCode(hax) + "\n\n" + getOldCredits(hax) + "\n\n" + getColors();
|
||||
return getInfo(hax) + "\n\n" + getCredits(hax) + "\n\n" + getLibraries(hax) + "\n\n" + getCode(hax) + "\n\n" + getColors();
|
||||
}
|
||||
|
||||
private static String getHeader(boolean hax, String normal, String hacked) {
|
||||
return (hax ? TextColor.RED : TextColor.YELLOW) + (hax ? hacked : normal) + "\n" +
|
||||
(hax ? TextColor.CYAN : TextColor.WHITE) + "==========================================+==========================================";
|
||||
(hax ? TextColor.CYAN : TextColor.WHITE) + "==========================+==========================";
|
||||
}
|
||||
|
||||
private static void addLines(StringBuilder sb, boolean hax, String alternate, String category, String... authors) {
|
||||
|
@ -61,7 +64,7 @@ public class GuiInfo extends Gui {
|
|||
private static String getLibraries(boolean hax) {
|
||||
StringBuilder sb = new StringBuilder(getHeader(hax, "Verwendete Programmbibliotheken", "U$3d 3xpl0its"));
|
||||
for(String lib : LIBRARIES) {
|
||||
sb.append("\n" + TextColor.LGRAY + "-> " + TextColor.NEON + lib);
|
||||
sb.append("\n" + TextColor.NEON + lib);
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
@ -69,7 +72,7 @@ public class GuiInfo extends Gui {
|
|||
private static String getCode(boolean hax) {
|
||||
StringBuilder sb = new StringBuilder(getHeader(hax, "Zusätzlicher Quellcode", "M0ar 3xpl01ts"));
|
||||
for(String lib : CODE) {
|
||||
sb.append("\n" + TextColor.LGRAY + "-> " + TextColor.NEON + lib);
|
||||
sb.append("\n" + TextColor.NEON + lib);
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
@ -78,37 +81,16 @@ public class GuiInfo extends Gui {
|
|||
StringBuilder sb = new StringBuilder();
|
||||
int num = 0;
|
||||
for(TextColor color : TextColor.values()) {
|
||||
if(num > 0)
|
||||
sb.append(' ');
|
||||
if(num == 14)
|
||||
sb.append('\n');
|
||||
if((color.code >= Log.CHR_COLORS1 && color.code <= Log.CHR_COLORE1) || (color.code >= Log.CHR_COLORS2 && color.code <= Log.CHR_COLORE2)) {
|
||||
sb.append(color + "#" + (char)(num < 10 ? ('0' + num) : ('A' + (num - 10))));
|
||||
sb.append(color + "#" + (char)(num < 10 ? ('0' + num) : ('A' + (num - 10))) + ' ');
|
||||
num++;
|
||||
}
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
private static String getOldCredits(boolean hax) {
|
||||
StringBuilder sb = new StringBuilder(getHeader(hax, "Ursprüngliche Mitwirkende", "Das Team -- Nicht TCQ"));
|
||||
|
||||
addLines(sb, hax, "Absolut größter Lamer des Universums", "Spielidee und ursprüngliche Umsetzung",
|
||||
"Markus Persson");
|
||||
addLines(sb, hax, "Crack und weitere Programmierung", "Spiel-Design, Programmierung und Grafiken",
|
||||
"Jens Bergensten", "Nathan Adams", "Ryan Holtz", "Michael Stoyke");
|
||||
addLines(sb, hax, "Entschlüsselung von Ressourcen", "Programmierung",
|
||||
"Erik Broes", "Paul Spooner", "Ryan Hitchman", "Elliot Segal");
|
||||
addLines(sb, hax, "Cracktro, Grafiken und Intromusik", "Töne und Geräusche",
|
||||
"Daniel Rosenfeld", "freesound.org");
|
||||
addLines(sb, hax, "Packing und Verbreitung", "Management, Administration und Spaß",
|
||||
"Carl Manneh", "Daniel Kaplan", "Lydia Winters");
|
||||
addLines(sb, hax, "Server und Hosting", "Zahlen und Statistiken",
|
||||
"Patrick Geuder");
|
||||
addLines(sb, hax, "Weiterer Dank und Grüße", "Entwickler von Mo' Creatures (Pferde usw.)",
|
||||
"John Olarte", "Kent Christian Jensen", "Dan Roque");
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
private static String getCredits(boolean hax) {
|
||||
StringBuilder sb = new StringBuilder(getHeader(hax, "Mitwirkende dieses Programms", "Das Team -- TCQ"));
|
||||
|
||||
|
@ -125,8 +107,8 @@ public class GuiInfo extends Gui {
|
|||
}
|
||||
|
||||
public void init(int width, int height) {
|
||||
this.add(new TransparentBox(10, 10, width - 20, height - 44, this.info, this.gm.theWorld != null && !this.gm.charEditor));
|
||||
this.add(new NavButton(0, height - 24, width, 24, GuiMenu.INSTANCE, "Zurück"));
|
||||
this.add(new MultiLabel(10, 10, width - 20, height - 44, this.info, false));
|
||||
this.add(new NavButton((width - 280) / 2, height - 20, 280, 0, GuiMenu.INSTANCE, "Zurück"));
|
||||
}
|
||||
|
||||
public String getTitle() {
|
|
@ -1,12 +1,12 @@
|
|||
package game.gui;
|
||||
package client.gui;
|
||||
|
||||
import game.Game;
|
||||
import game.gui.element.Bar;
|
||||
import game.gui.element.Label;
|
||||
import client.Client;
|
||||
import client.gui.element.Bar;
|
||||
import client.gui.element.Label;
|
||||
|
||||
public class GuiLoading extends Gui {
|
||||
public static interface Callback {
|
||||
void poll(Game gm, GuiLoading gui);
|
||||
void poll(Client gm, GuiLoading gui);
|
||||
}
|
||||
|
||||
private final String message;
|
||||
|
@ -19,7 +19,7 @@ public class GuiLoading extends Gui {
|
|||
|
||||
public static GuiLoading makeServerTask(String message) {
|
||||
return new GuiLoading(message, new Callback() {
|
||||
public void poll(Game gm, GuiLoading gui) {
|
||||
public void poll(Client gm, GuiLoading gui) {
|
||||
int progress = gm.progress;
|
||||
if(progress < 0) {
|
||||
gui.resetBar();
|
||||
|
@ -35,7 +35,7 @@ public class GuiLoading extends Gui {
|
|||
|
||||
public static GuiLoading makeWaitTask(String message) {
|
||||
return new GuiLoading(message, new Callback() {
|
||||
public void poll(Game gm, GuiLoading gui) {
|
||||
public void poll(Client gm, GuiLoading gui) {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -46,11 +46,11 @@ public class GuiLoading extends Gui {
|
|||
}
|
||||
|
||||
public void init(int width, int height) {
|
||||
this.taskLabel = this.add(new Label(0, 40, 500, 20, ""));
|
||||
this.progressBar1 = this.add(new Bar(0, 80, 500, 24));
|
||||
this.progressBar2 = this.add(new Bar(0, 120, 500, 24));
|
||||
this.taskLabel = this.add(new Label(0, 40, 500, 0, ""));
|
||||
this.progressBar1 = this.add(new Bar(0, 80, 500, 0));
|
||||
this.progressBar2 = this.add(new Bar(0, 120, 500, 0));
|
||||
this.shift();
|
||||
this.headerLabel = this.add(new Label(0, 40, width, 20, this.message));
|
||||
this.headerLabel = this.add(new Label(0, 40, width, 0, this.message));
|
||||
this.progressBar1.visible = false;
|
||||
this.progressBar2.visible = false;
|
||||
}
|
|
@ -1,21 +1,19 @@
|
|||
package game.gui;
|
||||
package client.gui;
|
||||
|
||||
import game.color.TextColor;
|
||||
import game.gui.character.GuiChar;
|
||||
import game.gui.character.GuiCharacters;
|
||||
import game.gui.element.ActButton;
|
||||
import game.gui.element.ActButton.Mode;
|
||||
import game.gui.element.Label;
|
||||
import game.gui.element.NavButton;
|
||||
import game.gui.element.Textbox;
|
||||
import game.gui.options.GuiOptions;
|
||||
import game.init.Config;
|
||||
import game.renderer.Drawing;
|
||||
import game.rng.Random;
|
||||
import game.util.ExtMath;
|
||||
import game.util.Splashes;
|
||||
import game.util.Timing;
|
||||
import game.window.Keysym;
|
||||
import client.Client;
|
||||
import client.gui.character.GuiChar;
|
||||
import client.gui.character.GuiCharacters;
|
||||
import client.gui.element.ActButton;
|
||||
import client.gui.element.ButtonCallback;
|
||||
import client.gui.element.Label;
|
||||
import client.gui.element.NavButton;
|
||||
import client.gui.element.PressType;
|
||||
import client.gui.options.GuiOptions;
|
||||
import client.renderer.Drawing;
|
||||
import client.window.Keysym;
|
||||
import common.color.TextColor;
|
||||
import common.rng.Random;
|
||||
import common.util.ExtMath;
|
||||
|
||||
public class GuiMenu extends Gui {
|
||||
public static final GuiMenu INSTANCE = new GuiMenu();
|
||||
|
@ -24,10 +22,10 @@ public class GuiMenu extends Gui {
|
|||
}
|
||||
|
||||
public void drawMainBackground() {
|
||||
if(this.gm.theWorld != null)
|
||||
if(this.gm.world != null)
|
||||
super.drawMainBackground();
|
||||
else
|
||||
this.gm.renderGlobal.renderStarField(this.gm.fb_x, this.gm.fb_y, 0x000000, 0xffffff, (float)this.ticks + (float)Timing.tick_fraction, this.rand);
|
||||
this.gm.renderGlobal.renderStarField(this.gm.fb_x, this.gm.fb_y, 0x000000, 0xffffff, (float)this.ticks + this.gm.getTickFraction(), this.rand);
|
||||
}
|
||||
|
||||
private final Random rand = new Random();
|
||||
|
@ -49,12 +47,16 @@ public class GuiMenu extends Gui {
|
|||
private boolean animStep;
|
||||
|
||||
public void init(int width, int height) {
|
||||
if(this.gm.theWorld == null) {
|
||||
if(this.gm.world == null) {
|
||||
this.ticks = 0;
|
||||
this.hacked = 0;
|
||||
this.resetAnimation();
|
||||
this.add(new ActButton(0, 0, 400, 24, new ActButton.Callback() {
|
||||
public void use(ActButton elem, Mode action) {
|
||||
this.add(new ActButton(0, 0, 180, 0, new ButtonCallback() {
|
||||
public void use(ActButton elem, PressType action) {
|
||||
if(action == PressType.SECONDARY) {
|
||||
GuiMenu.this.gm.joinDebugWorld();
|
||||
return;
|
||||
}
|
||||
if(GuiMenu.this.hacked == 9) {
|
||||
GuiMenu.this.hacked++;
|
||||
GuiMenu.this.splashLabel.setText(TextColor.VIOLET + "Hax!");
|
||||
|
@ -64,19 +66,20 @@ public class GuiMenu extends Gui {
|
|||
}
|
||||
}
|
||||
}, "Server beitreten"));
|
||||
this.add(new ActButton(0, 28, 400, 24, new ActButton.Callback() {
|
||||
public void use(ActButton elem, Mode action) {
|
||||
this.add(new ActButton(0, 20, 180, 0, new ButtonCallback() {
|
||||
public void use(ActButton elem, PressType action) {
|
||||
if(GuiMenu.this.hacked == 8)
|
||||
GuiMenu.this.hacked++;
|
||||
else
|
||||
GuiMenu.this.gm.displayGuiScreen(GuiOptions.getPage());
|
||||
GuiMenu.this.gm.displayGuiScreen(GuiServer.INSTANCE);
|
||||
}
|
||||
}, "Einstellungen"));
|
||||
this.infoButton = this.add(new ActButton(0, 56, 400, 24, new ActButton.Callback() {
|
||||
public void use(ActButton elem, Mode action) {
|
||||
}, "Schnellverbindung"));
|
||||
this.add(new NavButton(0, 40, 180, 0, GuiOptions.getPage(), "Einstellungen"));
|
||||
this.infoButton = this.add(new ActButton(0, 60, 180, 0, new ButtonCallback() {
|
||||
public void use(ActButton elem, PressType action) {
|
||||
GuiMenu.this.gm.displayGuiScreen(GuiMenu.this.hacked == 10 ? GuiInfo.HAX : GuiInfo.INSTANCE);
|
||||
}
|
||||
}, "Info / Über / Mitwirkende") {
|
||||
}, "Info / Mitwirkende") {
|
||||
public void drawHover() {
|
||||
if(GuiMenu.this.hacked == 10) {
|
||||
Drawing.drawRect(this.pos_x, this.pos_y, this.size_x, this.size_y, 0x287f00ff);
|
||||
|
@ -84,9 +87,9 @@ public class GuiMenu extends Gui {
|
|||
int width = Drawing.getWidth("Hax!");
|
||||
for(int z = 0; z < 64; z++) {
|
||||
Drawing.drawText("Hax!", GuiMenu.this.rand.zrange(Math.max(1, this.gm.fb_x - width)) +
|
||||
(int)(ExtMath.sin(((float)(GuiMenu.this.ticks + GuiMenu.this.rand.zrange(256)) + (float)Timing.tick_fraction) / 100.0f * (float)Math.PI * 2.0f) * 16.0f),
|
||||
(int)(ExtMath.sin(((float)(GuiMenu.this.ticks + GuiMenu.this.rand.zrange(256)) + this.gm.getTickFraction()) / 100.0f * (float)Math.PI * 2.0f) * 16.0f),
|
||||
GuiMenu.this.rand.zrange(Math.max(1, this.gm.fb_y - Font.YGLYPH)) +
|
||||
(int)(ExtMath.sin(((float)(GuiMenu.this.ticks + GuiMenu.this.rand.zrange(256)) + (float)Timing.tick_fraction) / 100.0f * (float)Math.PI * 2.0f) * 16.0f),
|
||||
(int)(ExtMath.sin(((float)(GuiMenu.this.ticks + GuiMenu.this.rand.zrange(256)) + this.gm.getTickFraction()) / 100.0f * (float)Math.PI * 2.0f) * 16.0f),
|
||||
0xff0000ff | (GuiMenu.this.rand.zrange(256) << 16));
|
||||
}
|
||||
}
|
||||
|
@ -95,34 +98,33 @@ public class GuiMenu extends Gui {
|
|||
}
|
||||
}
|
||||
});
|
||||
this.add(new NavButton(0, 102, 196, 24, GuiConvert.INSTANCE, "Welt konvertieren"));
|
||||
this.add(new ActButton(204, 102, 196, 24, new ActButton.Callback() {
|
||||
public void use(ActButton elem, ActButton.Mode action) {
|
||||
this.add(new ActButton(0, 90, 180, 0, new ButtonCallback() {
|
||||
public void use(ActButton elem, PressType action) {
|
||||
GuiMenu.this.gm.interrupted = true;
|
||||
}
|
||||
}, "Spiel beenden"));
|
||||
}, "Client schließen"));
|
||||
this.shift();
|
||||
this.add(new Label(4, /* this.gm.fb_y - 2 */ 0, 200, 20, TextColor.VIOLET + Config.VERSION, true));
|
||||
this.splashLabel = this.add(new Label(0, 160, width, 24, ""));
|
||||
this.add(new Label(4, 4, 200, 0, TextColor.VIOLET + Client.VERSION, true));
|
||||
this.splashLabel = this.add(new Label(0, 100, width, 0, ""));
|
||||
this.pickSplash();
|
||||
}
|
||||
else {
|
||||
this.add(new NavButton(0, 0, 400, 24, this.gm.charEditor ? GuiChar.INSTANCE : null, this.gm.charEditor ? "Zurück zum Charakter-Editor" : "Zurück zum Spiel"));
|
||||
this.add(new NavButton(0, 28, this.gm.charEditor ? 400 : 198, 24, GuiOptions.getPage(), "Einstellungen"));
|
||||
this.add(new NavButton(0, 0, 180, 0, this.gm.charEditor ? GuiChar.INSTANCE : null, this.gm.charEditor ? "Zurück zum Editor" : "Zurück zum Spiel"));
|
||||
this.add(new NavButton(0, 20, 180, 0, GuiOptions.getPage(), "Einstellungen"));
|
||||
if(!this.gm.charEditor)
|
||||
this.add(new NavButton(202, 28, 198, 24, GuiCharacters.INSTANCE, "Charakter"));
|
||||
this.add(new ActButton(0, 102, 400, 24, new ActButton.Callback() {
|
||||
public void use(ActButton elem, ActButton.Mode action) {
|
||||
this.add(new NavButton(0, 40, 180, 0, GuiCharacters.INSTANCE, "Charakter"));
|
||||
this.add(new ActButton(0, this.gm.charEditor ? 50 : 70, 180, 0, new ButtonCallback() {
|
||||
public void use(ActButton elem, PressType action) {
|
||||
GuiMenu.this.gm.unload(true);
|
||||
// GuiMenu.this.gm.displayGuiScreen(INSTANCE);
|
||||
}
|
||||
}, "Server verlassen und Verbindung trennen"));
|
||||
}, "Server verlassen"));
|
||||
this.shift();
|
||||
}
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return this.gm.theWorld == null ? "Hauptmenü" : "Menü";
|
||||
return this.gm.world == null ? "Hauptmenü" : "Menü";
|
||||
}
|
||||
|
||||
private void pickSplash() {
|
||||
|
@ -225,9 +227,9 @@ public class GuiMenu extends Gui {
|
|||
}
|
||||
|
||||
public void updateScreen() {
|
||||
if(this.gm.theWorld == null) {
|
||||
if(this.gm.world == null) {
|
||||
this.ticks++;
|
||||
if(this.gm.shift() && !(this.selected instanceof Textbox))
|
||||
if(this.gm.shift())
|
||||
this.pickSplash();
|
||||
this.updateAnimation();
|
||||
}
|
||||
|
@ -235,7 +237,7 @@ public class GuiMenu extends Gui {
|
|||
|
||||
public void key(Keysym key, boolean ctrl, boolean shift) {
|
||||
super.key(key, ctrl, shift);
|
||||
if(this.gm.theWorld == null) {
|
||||
if(this.gm.world == null) {
|
||||
if((key == Keysym.UP || key == Keysym.W) && (this.hacked == 0 || this.hacked == 1))
|
||||
this.hacked++;
|
||||
else if((key == Keysym.DOWN || key == Keysym.S) && (this.hacked == 2 || this.hacked == 3))
|
||||
|
@ -289,8 +291,8 @@ public class GuiMenu extends Gui {
|
|||
|
||||
public void drawOverlays() {
|
||||
super.drawOverlays();
|
||||
if(this.gm.theWorld == null) {
|
||||
int y = 164;
|
||||
if(this.gm.world == null) {
|
||||
int y = 99;
|
||||
int h = 16;
|
||||
int n = Drawing.getWidth(this.splashLabel.getText());
|
||||
Drawing.drawRect(0, y, this.gm.fb_x / 2 - n / 2 - 10, h, 0x7f7f00ff);
|
279
client/src/main/java/client/gui/GuiServer.java
Normal file
279
client/src/main/java/client/gui/GuiServer.java
Normal file
|
@ -0,0 +1,279 @@
|
|||
package client.gui;
|
||||
|
||||
import java.security.KeyPair;
|
||||
import java.security.PublicKey;
|
||||
import client.gui.GuiConnect.ServerInfo;
|
||||
import client.gui.element.ActButton;
|
||||
import client.gui.element.ButtonCallback;
|
||||
import client.gui.element.Element;
|
||||
import client.gui.element.Label;
|
||||
import client.gui.element.NavButton;
|
||||
import client.gui.element.PasswordField;
|
||||
import client.gui.element.PressType;
|
||||
import client.gui.element.Toggle;
|
||||
import client.gui.element.FieldAction;
|
||||
import client.gui.element.Field;
|
||||
import client.gui.element.FieldCallback;
|
||||
import client.vars.CVarCategory;
|
||||
import client.vars.Variable;
|
||||
import client.window.Window;
|
||||
import common.color.TextColor;
|
||||
import common.network.IPlayer;
|
||||
import common.util.EncryptUtil;
|
||||
|
||||
public class GuiServer extends Gui implements FieldCallback {
|
||||
public static final GuiServer INSTANCE = new GuiServer(null);
|
||||
|
||||
private final ServerInfo server;
|
||||
|
||||
private Field nameBox;
|
||||
private Field addrBox;
|
||||
private Field portBox;
|
||||
private Field userBox;
|
||||
private PasswordField passBox;
|
||||
private PasswordField accBox;
|
||||
private Label nameLabel;
|
||||
private Label addrLabel;
|
||||
private Label portLabel;
|
||||
private Label rangeLabel;
|
||||
private Label userLabel;
|
||||
private Label passLabel;
|
||||
private Label accLabel;
|
||||
private Label keyLabel;
|
||||
private Label idLabel;
|
||||
private Toggle encToggle;
|
||||
private ActButton keyButton;
|
||||
private ActButton resetButton;
|
||||
private ActButton copyKeyButton;
|
||||
private ActButton copyIdButton;
|
||||
private KeyPair keypair;
|
||||
private String keyDigest;
|
||||
private PublicKey serverKey;
|
||||
private String serverDigest;
|
||||
|
||||
public GuiServer(ServerInfo server) {
|
||||
this.server = server;
|
||||
}
|
||||
|
||||
@Variable(name = "srv_last_address", category = CVarCategory.SYSTEM, min = 1, max = 128, display = "Letzte Server-Adresse")
|
||||
private String lastAddr = "";
|
||||
@Variable(name = "srv_last_port", category = CVarCategory.SYSTEM, min = 1024, max = 32767, display = "Letzter Server-Port")
|
||||
private int lastPort = -1;
|
||||
@Variable(name = "srv_last_user", category = CVarCategory.SYSTEM, max = IPlayer.MAX_USER_LENGTH, display = "Letzter Server-Nutzer", validator = IPlayer.UserValidator.class)
|
||||
private String lastUser = "";
|
||||
@Variable(name = "srv_last_password", category = CVarCategory.SYSTEM, max = IPlayer.MAX_PASS_LENGTH, display = "Letztes Server-Passwort")
|
||||
private String lastPass = "";
|
||||
@Variable(name = "srv_last_access", category = CVarCategory.SYSTEM, max = IPlayer.MAX_PASS_LENGTH, display = "Letzter Server-Zugang")
|
||||
private String lastAcc = "";
|
||||
|
||||
public void init(int width, int height) {
|
||||
if(this.server != null) {
|
||||
this.nameBox = this.add(new Field(0, 0, 400, 0, 128, this, this.server.getName()));
|
||||
this.nameLabel = this.add(new Label(0, 0, 410, "Name in der Liste", true));
|
||||
this.keypair = this.server.getKeypair();
|
||||
this.keyDigest = this.keypair == null ? null : EncryptUtil.getXorSha512Hash(this.keypair.getPublic().getEncoded());
|
||||
}
|
||||
this.addrBox = this.add(new Field(0, 34, 400, 0, 128, this, this.server == null ? this.lastAddr : this.server.getAddress()));
|
||||
this.addrLabel = this.add(new Label(0, 34, 410, "Adresse / Hostname", true));
|
||||
int port = this.server == null ? this.lastPort : this.server.getPort();
|
||||
this.portBox = this.add(new Field(404, 34, 76, 0, 5, this, port < 0 ? "" : "" + port));
|
||||
this.portLabel = this.add(new Label(404, 34, 76, "Port", true));
|
||||
this.rangeLabel = this.add(new Label(370, 34 + Element.BASE_HEIGHT, 110, 0, "[1024..32767]", true));
|
||||
this.userBox = this.add(new Field(0, 68, 220, 0, IPlayer.MAX_USER_LENGTH, this, IPlayer.VALID_USER, this.server == null ? this.lastUser : this.server.getUser()));
|
||||
this.userLabel = this.add(new Label(0, 68, 220, "Benutzername", true));
|
||||
this.passBox = this.add(new PasswordField(0, this.server == null ? 102 : 136, 480, 0, IPlayer.MAX_PASS_LENGTH, this, this.server == null ? this.lastPass : this.server.getPassword()));
|
||||
this.passLabel = this.add(new Label(0, this.server == null ? 102 : 136, 480, (this.keypair == null ? "Anmelde" : "Ersatz") + "-Passwort (mind. 8 Zeichen)", true));
|
||||
this.accBox = this.add(new PasswordField(0, this.server == null ? 136 : 170, 480, 0, IPlayer.MAX_PASS_LENGTH, this, this.server == null ? this.lastAcc : this.server.getAccess()));
|
||||
this.accLabel = this.add(new Label(0, this.server == null ? 136 : 170, 480, "Server-Passwort (mind. 8 Zeichen)", true));
|
||||
this.add(new ActButton(241, this.server == null ? 166 : 254, 239, 0, new ButtonCallback() {
|
||||
public void use(ActButton elem, PressType action) {
|
||||
GuiServer.this.connect();
|
||||
}
|
||||
}, this.server == null ? "Verbinden" : (this.server.getName().isEmpty() ? "Hinzufügen" : "Übernehmen")));
|
||||
this.add(new NavButton(0, this.server == null ? 166 : 254, 239, 0, this.server != null ? GuiConnect.INSTANCE : GuiMenu.INSTANCE, "Zurück"));
|
||||
if(this.server != null) {
|
||||
this.keyButton = this.add(new ActButton(0, 102, 391, 0, new ButtonCallback() {
|
||||
public void use(ActButton elem, PressType action) {
|
||||
if(GuiServer.this.keypair == null) {
|
||||
GuiServer.this.keypair = EncryptUtil.createKeypair();
|
||||
GuiServer.this.keyDigest = EncryptUtil.getXorSha512Hash(GuiServer.this.keypair.getPublic().getEncoded());
|
||||
GuiServer.this.keyLabel.setText("Anmelde-Pubkey: " + EncryptUtil.KEY_ALGO_DISPLAY + " " + GuiServer.this.keyDigest);
|
||||
GuiServer.this.keyButton.setText("Schlüsselpaar entfernen");
|
||||
GuiServer.this.passLabel.setText("Ersatz-Passwort (mind. 8 Zeichen)");
|
||||
GuiServer.this.copyKeyButton.enabled = true;
|
||||
}
|
||||
else {
|
||||
final String name = GuiServer.this.nameBox.getText();
|
||||
final String addr = GuiServer.this.addrBox.getText();
|
||||
final String port = GuiServer.this.portBox.getText();
|
||||
final String pass = GuiServer.this.passBox.getText();
|
||||
final String acc = GuiServer.this.accBox.getText();
|
||||
final boolean reqEnc = GuiServer.this.encToggle.getValue();
|
||||
final KeyPair keys = GuiServer.this.keypair;
|
||||
final PublicKey key = GuiServer.this.serverKey;
|
||||
final String digest = GuiServer.this.keyDigest;
|
||||
final String sdigest = GuiServer.this.serverDigest;
|
||||
GuiServer.this.gm.displayGuiScreen(new GuiConfirm(new GuiConfirm.Callback() {
|
||||
public void confirm(boolean confirmed) {
|
||||
GuiServer.this.gm.displayGuiScreen(GuiServer.this);
|
||||
GuiServer.this.nameBox.setText(name);
|
||||
GuiServer.this.addrBox.setText(addr);
|
||||
GuiServer.this.portBox.setText(port);
|
||||
GuiServer.this.passBox.setText(pass);
|
||||
GuiServer.this.accBox.setText(acc);
|
||||
GuiServer.this.encToggle.setValue(reqEnc);
|
||||
GuiServer.this.serverKey = key;
|
||||
GuiServer.this.serverDigest = sdigest;
|
||||
GuiServer.this.idLabel.setText("Server-Pubkey: " + (key != null ? EncryptUtil.KEY_ALGO_DISPLAY + " " + GuiServer.this.serverDigest : "nicht vorhanden"));
|
||||
GuiServer.this.resetButton.enabled = key != null;
|
||||
GuiServer.this.copyIdButton.enabled = key != null;
|
||||
GuiServer.this.copyKeyButton.enabled = !confirmed;
|
||||
if(confirmed) {
|
||||
GuiServer.this.keypair = null;
|
||||
GuiServer.this.keyDigest = null;
|
||||
GuiServer.this.keyLabel.setText("Anmelde-Pubkey: nicht vorhanden");
|
||||
GuiServer.this.keyButton.setText("Neues Schlüsselpaar generieren");
|
||||
GuiServer.this.passLabel.setText("Anmelde-Passwort (mind. 8 Zeichen)");
|
||||
}
|
||||
else {
|
||||
GuiServer.this.keypair = keys;
|
||||
GuiServer.this.keyDigest = digest;
|
||||
GuiServer.this.keyLabel.setText("Anmelde-Pubkey: " + EncryptUtil.KEY_ALGO_DISPLAY + " " + GuiServer.this.keyDigest);
|
||||
GuiServer.this.keyButton.setText("Schlüsselpaar entfernen");
|
||||
GuiServer.this.passLabel.setText("Ersatz-Passwort (mind. 8 Zeichen)");
|
||||
}
|
||||
}
|
||||
}, "Schlüsselpaar wirklich entfernen?", "Wenn das Schlüsselpaar gelöscht wird, ist es nicht mehr möglich, sich damit\nauf dem Server zu identifizieren und sich anzumelden.\nDamit könnte der Zugriff auf den Server unmöglich werden.", "Schlüsselpaar löschen", "Abbrechen"));
|
||||
}
|
||||
}
|
||||
}, this.keypair == null ? "Neues Schlüsselpaar generieren" : "Schlüsselpaar entfernen"));
|
||||
this.copyKeyButton = this.add(new ActButton(395, 102, 85, 0, new ButtonCallback() {
|
||||
public void use(ActButton elem, PressType action) {
|
||||
if(GuiServer.this.keypair != null)
|
||||
Window.setClipboard(EncryptUtil.getArmoredPubkey(GuiServer.this.keypair.getPublic(), GuiServer.this.userBox.getText()));
|
||||
}
|
||||
}, "Kopieren"));
|
||||
this.copyKeyButton.enabled = this.keypair != null;
|
||||
this.keyLabel = this.add(new Label(0, 102, 480, "Anmelde-Pubkey: " + (this.keypair != null ? EncryptUtil.KEY_ALGO_DISPLAY + " " + this.keyDigest : "nicht vorhanden"), true));
|
||||
this.encToggle = this.add(new Toggle(0, 190, 480, 0, false, this.server.requiresEncryption(), null, "Nur Verschlüsselte Verbindung akzeptieren"));
|
||||
this.serverKey = this.server.getServerKey();
|
||||
this.serverDigest = this.serverKey == null ? null : EncryptUtil.getXorSha512Hash(this.serverKey.getEncoded());
|
||||
this.resetButton = this.add(new ActButton(0, 224, 391, 0, new ButtonCallback() {
|
||||
public void use(ActButton elem, PressType action) {
|
||||
if(GuiServer.this.serverKey != null) {
|
||||
GuiServer.this.serverKey = null;
|
||||
GuiServer.this.serverDigest = null;
|
||||
GuiServer.this.idLabel.setText("Server-Pubkey: nicht vorhanden");
|
||||
GuiServer.this.resetButton.enabled = false;
|
||||
GuiServer.this.copyIdButton.enabled = false;
|
||||
}
|
||||
}
|
||||
}, "Server-Identifizierung / Pubkey zurücksetzen"));
|
||||
this.resetButton.enabled = this.serverKey != null;
|
||||
this.copyIdButton = this.add(new ActButton(395, 224, 85, 0, new ButtonCallback() {
|
||||
public void use(ActButton elem, PressType action) {
|
||||
if(GuiServer.this.serverKey != null)
|
||||
Window.setClipboard(EncryptUtil.getArmoredPubkey(GuiServer.this.serverKey, GuiServer.this.nameBox.getText()));
|
||||
}
|
||||
}, "Kopieren"));
|
||||
this.copyIdButton.enabled = this.serverKey != null;
|
||||
this.idLabel = this.add(new Label(0, 224, 480, "Server-Pubkey: " + (this.serverKey != null ? EncryptUtil.KEY_ALGO_DISPLAY + " " + this.serverDigest : "nicht vorhanden"), true));
|
||||
}
|
||||
this.shift();
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return this.server == null ? "Mit Server verbinden" : (this.server.getName().isEmpty() ? "Server hinzufügen" : "Server bearbeiten");
|
||||
}
|
||||
|
||||
private void connect() {
|
||||
if(this.gm.world != null)
|
||||
return;
|
||||
String name = null;
|
||||
if(this.server != null) {
|
||||
name = this.nameBox.getText();
|
||||
if(name.isEmpty()) {
|
||||
this.nameLabel.setText(TextColor.RED + "Name in der Liste");
|
||||
return;
|
||||
}
|
||||
if(GuiConnect.INSTANCE.isNameTaken(name)) {
|
||||
this.nameLabel.setText("Name in der Liste - " + TextColor.RED + "Bereits vorhanden");
|
||||
return;
|
||||
}
|
||||
}
|
||||
String addr = this.addrBox.getText();
|
||||
if(addr.isEmpty()) {
|
||||
this.addrLabel.setText(TextColor.RED + "Adresse / Hostname");
|
||||
return;
|
||||
}
|
||||
int port = -1;
|
||||
if(this.portBox.getText().isEmpty()) {
|
||||
this.portLabel.setText(TextColor.RED + "Port");
|
||||
return;
|
||||
}
|
||||
else {
|
||||
try {
|
||||
port = Integer.parseInt(this.portBox.getText());
|
||||
}
|
||||
catch(NumberFormatException e) {
|
||||
this.rangeLabel.setText("[" + TextColor.RED + "1024..32767" + TextColor.RESET + "]");
|
||||
return;
|
||||
}
|
||||
if(port < 1024 || port > 32767) {
|
||||
this.rangeLabel.setText("[" + (port < 1024 ? TextColor.RED + "1024" + TextColor.RESET + "..32767" : "1024.." + TextColor.RED + "32767" + TextColor.RESET) + "]");
|
||||
return;
|
||||
}
|
||||
}
|
||||
String user = this.userBox.getText();
|
||||
if(user.isEmpty()) {
|
||||
this.userLabel.setText(TextColor.RED + "Benutzername");
|
||||
return;
|
||||
}
|
||||
String pass = this.passBox.getText();
|
||||
if(!pass.isEmpty() && pass.length() < 8) {
|
||||
this.passLabel.setText((this.keypair == null ? "Anmelde" : "Ersatz") + "-Passwort (" + TextColor.RED + "mind. 8 Zeichen" + TextColor.RESET + ")");
|
||||
return;
|
||||
}
|
||||
String acc = this.accBox.getText();
|
||||
if(!acc.isEmpty() && acc.length() < 8) {
|
||||
this.accLabel.setText("Zugang (" + TextColor.RED + "mind. 8 Zeichen" + TextColor.RESET + ")");
|
||||
return;
|
||||
}
|
||||
if(this.server == null) {
|
||||
this.lastAddr = addr;
|
||||
this.lastPort = port;
|
||||
this.lastUser = user;
|
||||
this.lastPass = pass;
|
||||
this.lastAcc = acc;
|
||||
this.gm.setDirty();
|
||||
GuiConnect.INSTANCE.connect(addr, port, user, pass, acc);
|
||||
}
|
||||
else {
|
||||
this.server.setData(name, addr, port, user, pass, acc, this.keypair, this.serverKey, this.encToggle.getValue());
|
||||
GuiConnect.INSTANCE.applyServer(this.server);
|
||||
}
|
||||
}
|
||||
|
||||
public void use(Field elem, FieldAction value) {
|
||||
if(value == FieldAction.SEND) {
|
||||
elem.setDeselected();
|
||||
this.connect();
|
||||
}
|
||||
else if(value == FieldAction.FOCUS) {
|
||||
if(elem == this.addrBox)
|
||||
this.addrLabel.setText("Adresse / Hostname");
|
||||
else if(elem == this.portBox) {
|
||||
this.portLabel.setText("Port");
|
||||
this.rangeLabel.setText("[1024..32767]");
|
||||
}
|
||||
else if(elem == this.userBox)
|
||||
this.userLabel.setText("Benutzername");
|
||||
else if(elem == this.passBox)
|
||||
this.passLabel.setText((this.keypair == null ? "Anmelde" : "Ersatz") + "-Passwort (mind. 8 Zeichen)");
|
||||
else if(elem == this.accBox)
|
||||
this.accLabel.setText("Server-Passwort (mind. 8 Zeichen)");
|
||||
else if(this.server != null && elem == this.nameBox)
|
||||
this.nameLabel.setText("Name in der Liste");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,36 +1,35 @@
|
|||
package game.util;
|
||||
package client.gui;
|
||||
|
||||
public abstract class Splashes {
|
||||
public static final String[] SPLASHES = {
|
||||
"Aus der TV-Werbung!",
|
||||
"Toll!",
|
||||
"Aus der Toiletten-Werbung!",
|
||||
"0% pur!",
|
||||
"Kann Nüsse enthalten!",
|
||||
"Besser als Crysis!",
|
||||
"Kann *.,-#+~ enthalten!",
|
||||
"Mehr Polygone!",
|
||||
"Sexy!",
|
||||
"Limitierte Edition!",
|
||||
"Blinkende Buchstaben!",
|
||||
"Erstellt von Notch!",
|
||||
"Es ist hier!",
|
||||
"Das Beste seiner Klasse!",
|
||||
"Es ist vollendet!",
|
||||
"Erstellt von Satan!",
|
||||
"Er ist hier!",
|
||||
"Das Schlimmste seiner Klasse!",
|
||||
"Es ist vollendet (nicht)!",
|
||||
"Mehr oder weniger frei von Drachen!",
|
||||
"Aufregung!",
|
||||
"Weniger als -5 verkauft!",
|
||||
"Einzigartig!",
|
||||
"Einen Haufen Scheiße auf YouTube!",
|
||||
"Indev!",
|
||||
"Dev!",
|
||||
"Alpha!",
|
||||
"Beta!",
|
||||
"Spinnen überall!",
|
||||
"Schau es dir an!",
|
||||
"Heilige Kuh, mann!",
|
||||
"Es ist ein Spiel!",
|
||||
"Hergestellt in Schweden!",
|
||||
"Hergestellt im Schattenland!",
|
||||
"Benutzt LWJGL!",
|
||||
"Retikulierende Splinen!",
|
||||
"Meine Kraft!",
|
||||
"Hurraaa!",
|
||||
"Einzelspieler!",
|
||||
"Tastatur ist kompatibel!",
|
||||
"Undokumentiert!",
|
||||
"Barren!",
|
||||
|
@ -41,17 +40,14 @@ public abstract class Splashes {
|
|||
"Überlebe!",
|
||||
"Verlies!",
|
||||
"Exklusiv!",
|
||||
"Die Knie der Biene!",
|
||||
"Weg mit O.P.P.!",
|
||||
"Mit Quellcode (mehr oder weniger)!",
|
||||
"Mit Klasse(n)!",
|
||||
"Wow!",
|
||||
"Immer noch nicht auf Steam - und das ist auch gut so!",
|
||||
"Niemals auf Steam - und das ist auch gut so!",
|
||||
"Oh, mann!",
|
||||
"Grauenvolle Community!",
|
||||
"Pixel!",
|
||||
"Teetsuuuuoooo!",
|
||||
"Kaaneeeedaaaa!",
|
||||
"Garfiiieeeeeeeld!",
|
||||
"Jetzt ohne Schwierigkeit!",
|
||||
"Verbessert!",
|
||||
"9% frei von Bugs!",
|
||||
|
@ -59,31 +55,26 @@ public abstract class Splashes {
|
|||
"13 Kräuter und Gewürze!",
|
||||
"Fettfrei!",
|
||||
"Absolut keine Memes!",
|
||||
"Kostenlose Zähne!",
|
||||
"Kostenlose Vampirzähne!",
|
||||
"Fragen Sie Ihnen Arzt oder Apotheker!",
|
||||
"Alle Bergleute sind willkommen!",
|
||||
"Cloud-Computing!",
|
||||
"Legal in Finnland!",
|
||||
"Frei von \"\"KI\"\"!",
|
||||
"Legal in Norwegen!",
|
||||
"Illegal in China!",
|
||||
"Schwer zu beschreiben!",
|
||||
"Technisch gesehen gut!",
|
||||
"Bringe den Speck nach Hause!",
|
||||
"Indie!",
|
||||
"GOTY!",
|
||||
"Ceci n'est pas une title screen!",
|
||||
"Euklidisch!",
|
||||
"Jetzt in 3D!",
|
||||
"Jetzt in 4D?!",
|
||||
"Bietet Inspiration!",
|
||||
"Herregud!",
|
||||
"Komplexe Zellvorgänge!",
|
||||
"Ja, Sir!",
|
||||
"Von Cowboys gespielt!",
|
||||
"Ja, Miss!",
|
||||
"Von Trollen gespielt!",
|
||||
"OpenGL 1.5 oder höher!",
|
||||
"Tausende von Farben!",
|
||||
"Millionen von Farben!",
|
||||
"Probiere es!",
|
||||
"Age of Wonders ist besser!",
|
||||
"Probiere die Pilzsuppe!",
|
||||
"Sensationell!",
|
||||
"Heiße Tamale, heiße heiße Tamale!",
|
||||
"Spiele ihn runter, Klavierkatze!",
|
||||
"Garantiert!",
|
||||
"Makroskopisch!",
|
||||
|
@ -94,27 +85,22 @@ public abstract class Splashes {
|
|||
"Von Melonen geliebt!",
|
||||
"Ultimative Edition!",
|
||||
"Merkwürdig!",
|
||||
"Du hast einen nagelneuen Schlüssel bekommen!",
|
||||
"Wasserfest!",
|
||||
"Nicht brennbar!",
|
||||
"Oha, du!",
|
||||
"Alles inklusive!",
|
||||
"Sag es deinen Freunden!",
|
||||
"NP ist nicht in P!",
|
||||
"Musik von C418 (DLC)!",
|
||||
"Viel zu oft live gestreamt!",
|
||||
"Heimgesucht!",
|
||||
"Polynomial!",
|
||||
"Terrestrisch!",
|
||||
"Alles ist voller Zerstörung!",
|
||||
"Voll mit Sternen, Planeten und Monden!",
|
||||
"Wissenschaftlich!",
|
||||
"Nicht so cool wie Spock!",
|
||||
"Trage nix bei und höre weg!",
|
||||
"Grabe niemals nach unten, wenn du keine Erze brauchst!",
|
||||
"Mache nie Pause!",
|
||||
"Nicht linear!",
|
||||
"Han hat zuerst geschossen!",
|
||||
"Schön dich zu sehen!",
|
||||
"Eimer mit Lava!",
|
||||
"Reite auf dem Schwein!",
|
||||
|
@ -124,25 +110,18 @@ public abstract class Splashes {
|
|||
"Holz schlagen!",
|
||||
"Von Klippen fallen!",
|
||||
"0% Zucker!",
|
||||
"150% hyperbol!",
|
||||
"Synecdoche!",
|
||||
"180% Alkohol!",
|
||||
"Lasst uns tanzne!",
|
||||
"Geheeimes Freitags-Update!",
|
||||
"Referenz-Implementation!",
|
||||
"Frei mit zwei.. äähhh fünf Typen mit Essen!",
|
||||
"Küsse den Himmel!",
|
||||
"20 GOTO 10!",
|
||||
"Verlet-Intregration!",
|
||||
"Peter Griffin!",
|
||||
"Verteile die Erde gut!",
|
||||
"Cogito ergo sum!",
|
||||
"4815162342 Zeilen Quellcode (287228 am 30.7.)!",
|
||||
"8263273626252622872652 Zeilen Quellcode (287228 am 30.7.)!",
|
||||
"Ein Skelett fiel heraus!",
|
||||
"Das Werk von Notch!",
|
||||
"Das Werk von Luzifer!",
|
||||
"Die Summe seiner Teile!",
|
||||
"BTAF war mal gut!",
|
||||
"Ich vermisse ADOM!",
|
||||
"umop-apisdn!",
|
||||
"mureh srednA!",
|
||||
"GTX750Ti!",
|
||||
"Bringe mir Mentos und Cola!",
|
||||
"Finger-leckend!",
|
||||
|
@ -162,25 +141,16 @@ public abstract class Splashes {
|
|||
"Doppelt gepuffert!",
|
||||
"Fan-Fiction!",
|
||||
"Flaxkikare!",
|
||||
"Jason! Jason! Jason!",
|
||||
"Heißer als die Sonne!",
|
||||
"Internet-Funktionalität!",
|
||||
"Autonom!",
|
||||
"Engagiere!",
|
||||
"Fantasie!",
|
||||
"DRR! DRR! DRR!",
|
||||
"Mau! Mau! Mau!",
|
||||
"Stoß es Wurzel runter!",
|
||||
"Regionale Ressourcen!",
|
||||
"Jaa, facepunch!",
|
||||
"Jaa, somethingawful!",
|
||||
"Jaa, /v/!",
|
||||
"Jaa, tigsource!",
|
||||
"Jaa, weinkraftforum!",
|
||||
"Jaa, worldofweinkraft!",
|
||||
"Buu, reddit!",
|
||||
"Jaa, 2pp!",
|
||||
"Goggle anllyticsed:DD :DDD:D!",
|
||||
"Unterstützt jetzt äöü!",
|
||||
"Unterstützt jetzt äöüß!",
|
||||
"Gebt uns Gordon!",
|
||||
"Gib deinem Kellner Trinkgeld!",
|
||||
"Macht viel Spaß!",
|
||||
|
@ -191,15 +161,12 @@ public abstract class Splashes {
|
|||
"Allmächtig!",
|
||||
"Huch!",
|
||||
"...!",
|
||||
"Bienen, Bienen, Bienen, Bienen!",
|
||||
"Jag känner en bot!",
|
||||
"Bienen, Mienen, Minen, W-!",
|
||||
"Dieser Text ist schwer bei der Standard-Auflösung zu lesen, aber auf 1080p ist es in Ordnung!",
|
||||
"Haha, LOL!",
|
||||
"Hampsterdance!",
|
||||
"Schalter und Erze!",
|
||||
"Menger-Schwamm!",
|
||||
"idspispopd!",
|
||||
"Eple (originale Version)!",
|
||||
"So frisch, so sauber!",
|
||||
"Schnell reagierende Portale!",
|
||||
"Probiere den Warp aus!",
|
||||
|
@ -207,10 +174,9 @@ public abstract class Splashes {
|
|||
"Oh, ok, NPCs!",
|
||||
"Endlich mit Leitern!",
|
||||
"Gruselig!",
|
||||
"Spiele Minenkraft, schaue Topgear, bekomme Schwein!",
|
||||
"Darüber gewittert!",
|
||||
"Spring hoch, spring hoch, und komme runter!",
|
||||
"Joel ist klasse!",
|
||||
"Strahlung ist klasse!",
|
||||
"Ein Rätsel, in einen Mythos verwoben!",
|
||||
"Riesige Landeszüge voll mit TNT!",
|
||||
"Willkommen zu deinem Ende! Muahahahahahaha!",
|
||||
|
@ -222,23 +188,21 @@ public abstract class Splashes {
|
|||
"\"Fast nie\" ist ein interessantes Konzept!",
|
||||
"Eine Menge Wahrheitigkeit!",
|
||||
"Der TNT-Block ist ein Spion!",
|
||||
"Turing-vollständig!",
|
||||
"Turing-unvollständig!",
|
||||
"Es ist bahnbrechend!",
|
||||
"Lasst unsere Schlachten beginnen!",
|
||||
"Der Himmel ist die Grenze - oder auch nicht!",
|
||||
"Jeb hat tolle Haare!",
|
||||
"Ryan hat auch tolle Haare!",
|
||||
"Dein PC hat tolle Haare, mach das Ding mal sauber!",
|
||||
"Shen hat auch tolle Haare!",
|
||||
"Gelegentliches Spielen!",
|
||||
"Unbesiegt!",
|
||||
"Ein Bisschen wie Lemmings!",
|
||||
"Folge dem Zug, CJ!",
|
||||
"Macht von Synergie Verwendung!",
|
||||
"Diese Nachricht wird niemals als Splash-Text erscheinen, ist das nicht komisch?",
|
||||
"DungeonQuest ist unfair!",
|
||||
"Diese Nachricht sollte niemals als Splash-Text erscheinen, oder etwa doch? Trololololol!",
|
||||
"0815!",
|
||||
"666!",
|
||||
"Geh zu den fernen Ländern und weiter!",
|
||||
"Tyrion würde es lieben!",
|
||||
"Probiere auch Stellaris!",
|
||||
"Probiere auch Garry's Mod!",
|
||||
"Probiere auch GZDoom!",
|
||||
|
@ -252,52 +216,43 @@ public abstract class Splashes {
|
|||
"Brot ist Schmerz!",
|
||||
"Lese mehr Bücher!",
|
||||
"Khaaaaaaaaan!",
|
||||
"Weniger süchtig machend als TV Tropes!",
|
||||
"Weniger süchtig machend als [zensiert da NSFW]!",
|
||||
"Mehr süchtig machend als Limonade!",
|
||||
"Größer als eine Brotkiste!",
|
||||
"Millionen von Pfirsichen!",
|
||||
"Fnord!",
|
||||
"Dies ist meine echte Gestalt! Muahahahaha!",
|
||||
"Habe Dre vollkommen vergessen!",
|
||||
"Verschwende keine Zeit mit den Klonen!",
|
||||
"Kürbiskopf!",
|
||||
"Hobo humping slobo babe!",
|
||||
"Erstellt von Jeb!",
|
||||
"Verschwende keine Zeit mit \"\"KI\"\"!",
|
||||
"Erstellt von einer Katze!",
|
||||
"Hat kein Ende!",
|
||||
"Endlich vollständig!",
|
||||
"Voll mit Features!",
|
||||
"Stiefel mit dem Fell!",
|
||||
"Stop, hammertime!",
|
||||
"Testificates!",
|
||||
"Test!",
|
||||
"Nicht konventionell!",
|
||||
"Homeomorphisch zu einer 3-Kugel!",
|
||||
"Nicht kommerziell!",
|
||||
"Vermeidet nicht doppelte Verneinung!",
|
||||
"Platziere ALL die Blöcke!",
|
||||
"Macht Walzen!",
|
||||
"Erfüllt Erwartungen!",
|
||||
"Spielen am PC seit 1873!",
|
||||
"Ghoughpteighbteau tchoghs!",
|
||||
"Spielen am PC seit 1992!",
|
||||
"Deja vu!",
|
||||
"Deja vu!",
|
||||
"Hab deine Nase!",
|
||||
"Haley liebt Elan!",
|
||||
"Hat keine Angst vor der großen, schwarzen Fledermaus!",
|
||||
"Benutzt nicht das U-Wort!",
|
||||
"Nicht wirklich leicht!",
|
||||
"Bis nächsten Freitag oder so!",
|
||||
"Von den Straßen von Södermalm!",
|
||||
"150 BPM für 400000 Minuten!",
|
||||
"Von den Straßen von Nibelheim!",
|
||||
"Technologisch!",
|
||||
"Funk Soul Bruder!",
|
||||
"Pumpa kungen!",
|
||||
"Hallo Japan!",
|
||||
"Hallo Japan!",
|
||||
"Hallo Korea!",
|
||||
"Hallo Wales!",
|
||||
"Hallo Polen!",
|
||||
"Hallo China!",
|
||||
"Hallo China!",
|
||||
"Hallo Russland!",
|
||||
"Hallo Griechenland!",
|
||||
"Mein Leben für Aiur!",
|
||||
"Mein Leben für Aiur (warte mal..)!",
|
||||
"Lenny lenny = new Lenny(\"(°^°)\");",
|
||||
"Ich sehe dein Wortschatz hat sich verbessert!",
|
||||
"Wer hat es dort hin getan?",
|
||||
|
@ -305,14 +260,14 @@ public abstract class Splashes {
|
|||
"if not ok then return end",
|
||||
"Mehrfarbig!",
|
||||
"FUNKY LOL",
|
||||
"SOPA bedeutet LOSER in Schwedisch!",
|
||||
"Copyright bedeutet LOSER in allen Sprachen!",
|
||||
"Große Spitze Zähne!",
|
||||
"Mein Shizun bewacht das Tor!",
|
||||
"Mmmph, mmph!",
|
||||
"Füttere keine Avocados an Papageien!",
|
||||
"Füttere keine Landminen an Piranhas!",
|
||||
"Schwerter für alle!",
|
||||
"Bitteee antworte meinem Tweet! (Nutzer wurde gebannt)",
|
||||
".party()!",
|
||||
".party().crash().commitWarcrimes().forTheEmperor()!",
|
||||
"Nehme ihr Kissen!",
|
||||
"Lege diesen Keks weg!",
|
||||
"Extrem gruselig!",
|
||||
|
@ -320,26 +275,21 @@ public abstract class Splashes {
|
|||
"Jetzt mit extra Sprengstoff!",
|
||||
"Nicht kompatibel zu Java 6!",
|
||||
"Oha.",
|
||||
"HURNERJSGER?",
|
||||
"Was'n los, Doc?",
|
||||
"Enthält jetzt 0 zufällige tägliche Katzen!",
|
||||
"Das ist Numberwang!",
|
||||
"((pls rt)) -- Der Vogel ist tot!",
|
||||
"Willst du meinem Server beitreten?",
|
||||
"Mach einen großen Zaun drum herum! Oder du wirst v-",
|
||||
"Lege eine Landmine drüber!",
|
||||
"Eines Tages, irgendwann in der Zukunft, wird mein Werk zitiert werden!",
|
||||
"Eines Tages, irgendwann in der Zukunft, wird mein Werk r3- ÄÄHHH kopiert werden!",
|
||||
"Jetzt mit zusätzlichem Zeug!",
|
||||
"Zusätzliche Dinge!",
|
||||
"Hurra, Atombomben für alle!",
|
||||
"So süß, wie ein schöner Bon-Bon!",
|
||||
"Poppende Tags!",
|
||||
"So süß, wie ein schöner ****!",
|
||||
"Sehr einflussreich in seinem Kreis!",
|
||||
"Jetzt mit Mehrspieler!",
|
||||
"Stehe aus deinem Grab auf!",
|
||||
"Warnung! Ein großes Kampfschiff \"SHEN\" nähert sich schnell!",
|
||||
"Der blaue Krieger hat das Essen beschossen!",
|
||||
"Renn, Feigling! Ich hunger!",
|
||||
"Geschmack ohne Würze!",
|
||||
"Seltsam, aber nicht fremd!",
|
||||
"Härter als Diamanten, Reich wie Creme!",
|
||||
|
@ -355,14 +305,13 @@ public abstract class Splashes {
|
|||
"Bau mir einen Tisch, einen funkigen Tisch!",
|
||||
"Nehm den Aufzug in die Hölle!",
|
||||
"Hör auf vernünftig zu sein, das hier ist das Internet!",
|
||||
"/give @a tnt 67108864 7",
|
||||
"/give * tnt 67108864 7",
|
||||
"Das ist gut für 3D Realms.",
|
||||
"Jeder Computer ist ein Laptop, wenn du tapfer genug bist!",
|
||||
"Mach es alles, jede Sache!",
|
||||
"Wo ist kein Licht, da kann Spinne!",
|
||||
"GNU Terry Pratchett",
|
||||
"Jetzt Java 8!",
|
||||
"MeinKraft!",
|
||||
"Jetzt Java 21!",
|
||||
"Immer noch zu viele Bugs!",
|
||||
"Wird nicht laggen!",
|
||||
"Er hat es ruiniert!",
|
||||
|
@ -370,7 +319,6 @@ public abstract class Splashes {
|
|||
"OpenGL 2.0+ (definitiv nicht unterstützt)!",
|
||||
"Keine Segfaults (nicht) möglich!",
|
||||
"Keine Abstürze (un)möglich!",
|
||||
"Alpha!",
|
||||
"Enthält Bugs!",
|
||||
"Enthält Mäuse!",
|
||||
"Enthält Gewalt!",
|
||||
|
@ -379,6 +327,7 @@ public abstract class Splashes {
|
|||
"Du hattest eine. aufgabe.",
|
||||
"Spinnen können TNT1 A 0 sein!",
|
||||
"RTFM!",
|
||||
"Hex, nur mit mehr Ameisen!",
|
||||
"Vorherrschaft des Imperiums!",
|
||||
"Vorherrschaft der Eldar!",
|
||||
"Vorherrschaft der Drukhari!",
|
||||
|
@ -409,6 +358,11 @@ public abstract class Splashes {
|
|||
"Eimer mit Wasser!",
|
||||
"Hergestellt in Deutschland!",
|
||||
"Hergestellt in China!",
|
||||
"Jetzt mit Einzelspieler!"
|
||||
"Jetzt ohne Einzelspieler!",
|
||||
"Jetzt mit tieferen Schluchten!",
|
||||
"Was bist du denn für ein hübsches Ding?",
|
||||
"[TEXT ZENSIERT]",
|
||||
"Mehr Energie!",
|
||||
"Maximale Energie!"
|
||||
};
|
||||
}
|
|
@ -1,12 +1,12 @@
|
|||
package game.gui;
|
||||
package client.gui;
|
||||
|
||||
import game.properties.IStringSerializable;
|
||||
import game.util.Displayable;
|
||||
import game.vars.CVarCategory;
|
||||
import game.vars.Variable;
|
||||
import game.vars.Variable.IntType;
|
||||
import client.vars.CVarCategory;
|
||||
import client.vars.Variable;
|
||||
import client.vars.Variable.IntType;
|
||||
import common.util.Displayable;
|
||||
import common.util.Identifyable;
|
||||
|
||||
public enum Style implements IStringSerializable, Displayable {
|
||||
public enum Style implements Identifyable, Displayable {
|
||||
DEFAULT("default", "Standard"), SHINY("shiny", "Glänzend"), GRAY("gray", "Grau"), BLUE("blue", "Blau"), CUSTOM("custom", "Angepasst");
|
||||
|
||||
public final String id;
|
||||
|
@ -17,9 +17,9 @@ public enum Style implements IStringSerializable, Displayable {
|
|||
this.name = name;
|
||||
}
|
||||
|
||||
@Variable(type = IntType.COLOR, name = "color_border_top", category = CVarCategory.GUI, display = "Umrahmung oben / l.")
|
||||
@Variable(type = IntType.COLOR, name = "color_border_top", category = CVarCategory.GUI, display = "Umrahmung A")
|
||||
public int brdr_top;
|
||||
@Variable(type = IntType.COLOR, name = "color_border_btm", category = CVarCategory.GUI, display = "Umrahmung unten / r.")
|
||||
@Variable(type = IntType.COLOR, name = "color_border_btm", category = CVarCategory.GUI, display = "Umrahmung B")
|
||||
public int brdr_btm;
|
||||
|
||||
@Variable(type = IntType.COLOR, name = "color_button_top", category = CVarCategory.GUI, display = "Knopf oben")
|
|
@ -1,4 +1,4 @@
|
|||
package game.gui.character;
|
||||
package client.gui.character;
|
||||
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.File;
|
||||
|
@ -8,61 +8,67 @@ import java.io.IOException;
|
|||
import java.io.InputStream;
|
||||
import java.nio.file.Files;
|
||||
import java.util.Arrays;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.opengl.GL13;
|
||||
|
||||
import game.Game;
|
||||
import game.Game.FileMode;
|
||||
import game.collect.Lists;
|
||||
import game.dimension.DimType;
|
||||
import game.dimension.Dimension;
|
||||
import game.entity.npc.Alignment;
|
||||
import game.entity.npc.CharacterInfo;
|
||||
import game.entity.npc.EntityHuman;
|
||||
import game.entity.npc.EntityNPC;
|
||||
import game.entity.npc.SpeciesInfo;
|
||||
import game.entity.types.EntityLiving;
|
||||
import game.gui.GuiLoading;
|
||||
import game.gui.element.ActButton;
|
||||
import game.gui.element.ActButton.Mode;
|
||||
import game.gui.element.Element;
|
||||
import game.gui.element.GuiList;
|
||||
import game.gui.element.Label;
|
||||
import game.gui.element.ListEntry;
|
||||
import game.gui.element.NavButton;
|
||||
import game.gui.element.Slider;
|
||||
import game.gui.element.Textbox;
|
||||
import game.gui.element.TransparentBox;
|
||||
import game.gui.element.Textbox.Action;
|
||||
import game.init.EntityEggInfo;
|
||||
import game.init.EntityRegistry;
|
||||
import game.init.SpeciesRegistry;
|
||||
import game.init.UniverseRegistry;
|
||||
import game.init.SpeciesRegistry.ModelType;
|
||||
import game.log.Log;
|
||||
import game.network.Player;
|
||||
import game.packet.CPacketAction;
|
||||
import game.packet.CPacketMessage;
|
||||
import game.packet.CPacketSkin;
|
||||
import game.properties.IStringSerializable;
|
||||
import game.renderer.Drawing;
|
||||
import game.renderer.GlState;
|
||||
import game.renderer.ItemRenderer;
|
||||
import game.renderer.entity.RenderManager;
|
||||
import game.renderer.texture.EntityTexManager;
|
||||
import game.rng.Random;
|
||||
import game.util.Displayable;
|
||||
import game.util.FileCallback;
|
||||
import game.util.FileUtils;
|
||||
import game.util.SkinConverter;
|
||||
import game.util.Util;
|
||||
import game.vars.CVarCategory;
|
||||
import game.vars.EnumVar;
|
||||
import game.vars.EnumVar.EnumFunction;
|
||||
import game.vars.Variable;
|
||||
import game.window.Button;
|
||||
import client.Client;
|
||||
import client.Client.FileMode;
|
||||
import client.gui.FileCallback;
|
||||
import client.gui.Font;
|
||||
import client.gui.GuiLoading;
|
||||
import client.gui.element.ActButton;
|
||||
import client.gui.element.Element;
|
||||
import client.gui.element.GuiList;
|
||||
import client.gui.element.Label;
|
||||
import client.gui.element.ListEntry;
|
||||
import client.gui.element.MultiLabel;
|
||||
import client.gui.element.NavButton;
|
||||
import client.gui.element.PressType;
|
||||
import client.gui.element.Slider;
|
||||
import client.gui.element.SliderCallback;
|
||||
import client.gui.element.FieldAction;
|
||||
import client.gui.element.Area;
|
||||
import client.gui.element.ButtonCallback;
|
||||
import client.gui.element.Field;
|
||||
import client.gui.element.FieldCallback;
|
||||
import client.renderer.Drawing;
|
||||
import client.renderer.GlState;
|
||||
import client.renderer.ItemRenderer;
|
||||
import client.renderer.entity.RenderManager;
|
||||
import client.renderer.texture.EntityTexManager;
|
||||
import client.util.FileUtils;
|
||||
import client.util.SkinConverter;
|
||||
import client.vars.CVarCategory;
|
||||
import client.vars.EnumVar;
|
||||
import client.vars.Variable;
|
||||
import client.vars.EnumVar.EnumFunction;
|
||||
import client.window.Button;
|
||||
import common.collect.Lists;
|
||||
import common.dimension.DimType;
|
||||
import common.dimension.Dimension;
|
||||
import common.entity.npc.Alignment;
|
||||
import common.entity.npc.CharacterInfo;
|
||||
import common.entity.npc.EntityHuman;
|
||||
import common.entity.npc.EntityNPC;
|
||||
import common.entity.npc.SpeciesInfo;
|
||||
import common.entity.types.EntityLiving;
|
||||
import common.init.EntityInfo;
|
||||
import common.init.EntityRegistry;
|
||||
import common.init.SpeciesRegistry;
|
||||
import common.init.UniverseRegistry;
|
||||
import common.init.SpeciesRegistry.ModelType;
|
||||
import common.log.Log;
|
||||
import common.network.IPlayer;
|
||||
import common.packet.CPacketAction;
|
||||
import common.packet.CPacketMessage;
|
||||
import common.packet.CPacketSkin;
|
||||
import common.rng.Random;
|
||||
import common.util.Displayable;
|
||||
import common.util.Identifyable;
|
||||
import common.util.Util;
|
||||
|
||||
public class GuiChar extends GuiList<GuiChar.SkinEntry>
|
||||
{
|
||||
|
@ -96,7 +102,7 @@ public class GuiChar extends GuiList<GuiChar.SkinEntry>
|
|||
}
|
||||
}
|
||||
|
||||
public void draw(int x, int y, int mouseX, int mouseY, boolean hovered)
|
||||
public void draw(int x, int y, int width, int height, int mouseX, int mouseY, boolean hovered)
|
||||
{
|
||||
String str =
|
||||
(this.skinFile != null ? this.skinFile.getName() : (
|
||||
|
@ -108,7 +114,7 @@ public class GuiChar extends GuiList<GuiChar.SkinEntry>
|
|||
Drawing.drawText(str, x + 64 + 3, y, 0xff000000 | (this.charinfo == null ?
|
||||
0xffffff : this.charinfo.color1 | this.charinfo.color2));
|
||||
if(this.charinfo != null)
|
||||
Drawing.drawText(this.charinfo.skin, x + 64 + 3, y + 18, 0xffc0c0c0);
|
||||
Drawing.drawTextRight(this.charinfo.skin, x + width - 2, y + height - Font.YGLYPH, 0xffc0c0c0);
|
||||
|
||||
GlState.color(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
|
||||
|
@ -128,7 +134,7 @@ public class GuiChar extends GuiList<GuiChar.SkinEntry>
|
|||
EntityTexManager.altLayer = this.dynId;
|
||||
EntityTexManager.altNpcLayer = this.dynId == -1 && this.charinfo != null ? this.charinfo.skin : null;
|
||||
drawEntity(x + 32, y + 60, 28.0f
|
||||
* Math.min(1.8f / GuiChar.this.gm.thePlayer.height, 1.5f / GuiChar.this.gm.thePlayer.width), -45.0f, -20.0f, GuiChar.this.gm.thePlayer);
|
||||
* Math.min(1.8f / GuiChar.this.gm.player.height, 1.5f / GuiChar.this.gm.player.width), -45.0f, -20.0f, GuiChar.this.gm.player);
|
||||
GuiChar.this.gm.cameraUsed = flag;
|
||||
EntityTexManager.altTexture = null;
|
||||
EntityTexManager.altLayer = -1;
|
||||
|
@ -161,7 +167,15 @@ public class GuiChar extends GuiList<GuiChar.SkinEntry>
|
|||
// }
|
||||
// }
|
||||
GuiChar.this.templateButton.enabled = this.charinfo != null;
|
||||
GuiChar.this.gm.getNetHandler().addToSendQueue(new CPacketSkin(this.skinImage, this.skinImage != null ? null : this.charinfo.skin, this.model));
|
||||
if(this.skinImage == null) {
|
||||
GuiChar.this.gm.getNetHandler().addToSendQueue(new CPacketSkin(null, this.charinfo.skin));
|
||||
}
|
||||
else {
|
||||
int[] img = new int[this.model.texWidth * this.model.texHeight];
|
||||
this.skinImage.getRGB(0, 0, this.skinImage.getWidth(), this.skinImage.getHeight(), img, 0, this.skinImage.getWidth());
|
||||
GuiChar.this.gm.getNetHandler().addToSendQueue(new CPacketSkin(EntityTexManager.imageToComp(img, this.model), null));
|
||||
}
|
||||
// GuiChar.this.gm.getNetHandler().addToSendQueue(new CPacketSkin(this.skinImage, this.skinImage != null ? null : this.charinfo.skin, this.model));
|
||||
GuiChar.this.currentSkin = this.skinFile != null ? this.skinFile.getName() : this.charinfo.skin;
|
||||
GuiChar.this.waiting = false;
|
||||
}
|
||||
|
@ -206,7 +220,7 @@ public class GuiChar extends GuiList<GuiChar.SkinEntry>
|
|||
}
|
||||
}
|
||||
|
||||
public static enum FilterType implements IStringSerializable, Displayable {
|
||||
public static enum FilterType implements Identifyable, Displayable {
|
||||
ALL("all", "Alle anzeigen"), CUSTOM("custom", "Nur eigene"), NPC("preset", "Nur vorgegebene"), SPECIES("species", "Nur Spezies"), SPECIES_CUSTOM("species_custom", "Spezies und eigene");
|
||||
|
||||
private final String name;
|
||||
|
@ -228,8 +242,8 @@ public class GuiChar extends GuiList<GuiChar.SkinEntry>
|
|||
|
||||
public static class FilterFunction implements EnumFunction<FilterType> {
|
||||
public void apply(EnumVar cv, FilterType value) {
|
||||
if(Game.getGame().open instanceof GuiChar)
|
||||
Game.getGame().displayGuiScreen(Game.getGame().open);
|
||||
if(Client.CLIENT.open instanceof GuiChar)
|
||||
Client.CLIENT.displayGuiScreen(Client.CLIENT.open);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -239,7 +253,8 @@ public class GuiChar extends GuiList<GuiChar.SkinEntry>
|
|||
private ActButton templateButton;
|
||||
private DragAdjust adjust;
|
||||
private ActButton dimButton;
|
||||
private TransparentBox descLines;
|
||||
private MultiLabel descLines;
|
||||
private ActButton cancelButton;
|
||||
private float yaw = -15.0f;
|
||||
private float pitch = -15.0f;
|
||||
private boolean waiting = true;
|
||||
|
@ -256,16 +271,16 @@ public class GuiChar extends GuiList<GuiChar.SkinEntry>
|
|||
{
|
||||
super.init(width, height);
|
||||
this.waiting = true;
|
||||
this.setDimensions(400, height, 32, height - 32);
|
||||
this.setDimensions(390, height, 32, height - 32);
|
||||
if(this.gm.getRenderManager().gm == null) {
|
||||
this.unload();
|
||||
this.adjust = null;
|
||||
return;
|
||||
}
|
||||
this.currentSkin = this.gm.thePlayer != null && !EntityTexManager.hasCustomSkin(this.gm.thePlayer.getId()) ? this.gm.thePlayer.getChar() : null;
|
||||
this.load(this.gm.thePlayer == null ? ModelType.HUMANOID : this.gm.thePlayer.getModel(), this.gm.thePlayer != null ? this.gm.thePlayer.getSpecies() : SpeciesRegistry.CLASSES.get(EntityHuman.class));
|
||||
this.add(new ActButton(4, 4, 194, 24, new ActButton.Callback() {
|
||||
public void use(ActButton elem, Mode action) {
|
||||
this.currentSkin = this.gm.player != null && !EntityTexManager.hasCustomSkin(this.gm.player.getId()) ? this.gm.player.getChar() : null;
|
||||
this.load(this.gm.player == null ? ModelType.HUMANOID : this.gm.player.getModel(), this.gm.player != null ? this.gm.player.getSpecies() : SpeciesRegistry.CLASSES.get(EntityHuman.class));
|
||||
this.add(new ActButton(2, 12, 193, 0, new ButtonCallback() {
|
||||
public void use(ActButton elem, PressType action) {
|
||||
GuiChar.this.gm.showFileDialog(FileMode.FILE_LOAD_MULTI, "Skin konvertieren", TEXTURE_FOLDER, new FileCallback() {
|
||||
public void selected(File file) {
|
||||
if(SkinConverter.convertSkin(file, TEXTURE_FOLDER, false))
|
||||
|
@ -274,8 +289,8 @@ public class GuiChar extends GuiList<GuiChar.SkinEntry>
|
|||
});
|
||||
}
|
||||
}, "Importieren: Standard"));
|
||||
this.add(new ActButton(202, 4, 194, 24, new ActButton.Callback() {
|
||||
public void use(ActButton elem, Mode action) {
|
||||
this.add(new ActButton(197, 12, 193, 0, new ButtonCallback() {
|
||||
public void use(ActButton elem, PressType action) {
|
||||
GuiChar.this.gm.showFileDialog(FileMode.FILE_LOAD_MULTI, "Skin konvertieren (schlank)", TEXTURE_FOLDER, new FileCallback() {
|
||||
public void selected(File file) {
|
||||
if(SkinConverter.convertSkin(file, TEXTURE_FOLDER, true))
|
||||
|
@ -284,14 +299,14 @@ public class GuiChar extends GuiList<GuiChar.SkinEntry>
|
|||
});
|
||||
}
|
||||
}, "Importieren: Schlank"));
|
||||
this.addSelector("char_filter_species", 400, 4, 300, 24);
|
||||
this.add(new ActButton(4, height - 28, 194, 24, new ActButton.Callback() {
|
||||
public void use(ActButton elem, Mode action) {
|
||||
this.addSelector("char_filter_species", 392, 12, 250, 0);
|
||||
this.add(new ActButton(2, height - 30, 193, 0, new ButtonCallback() {
|
||||
public void use(ActButton elem, PressType action) {
|
||||
GuiChar.this.gm.displayGuiScreen(GuiChar.this);
|
||||
}
|
||||
}, "Neu laden"));
|
||||
this.templateButton = this.add(new ActButton(202, height - 28, 194, 24, new ActButton.Callback() {
|
||||
public void use(ActButton elem, Mode action) {
|
||||
this.templateButton = this.add(new ActButton(197, height - 30, 193, 0, new ButtonCallback() {
|
||||
public void use(ActButton elem, PressType action) {
|
||||
SkinEntry skin = GuiChar.this.getSelected();
|
||||
if(skin != null && skin.getLocation() != null) {
|
||||
String loc = skin.getLocation();
|
||||
|
@ -307,9 +322,9 @@ public class GuiChar extends GuiList<GuiChar.SkinEntry>
|
|||
}
|
||||
catch(Exception e) {
|
||||
if(e instanceof FileNotFoundException)
|
||||
Log.JNI.warn("Textur ist nicht zum Kopieren vorhanden: " + EntityNPC.getSkinTexture(loc));
|
||||
Log.IO.warn("Textur ist nicht zum Kopieren vorhanden: " + EntityNPC.getSkinTexture(loc));
|
||||
else
|
||||
Log.JNI.error(e, "Konnte Textur nicht kopieren");
|
||||
Log.IO.error(e, "Konnte Textur nicht kopieren");
|
||||
}
|
||||
finally {
|
||||
if(in != null) {
|
||||
|
@ -324,74 +339,81 @@ public class GuiChar extends GuiList<GuiChar.SkinEntry>
|
|||
}
|
||||
}
|
||||
}, "Vorlage kopieren"));
|
||||
this.adjust = this.add(new DragAdjust(width / 2 - 230, height - 64 - 640, 460, 640));
|
||||
if(width >= 784 + 460 && height >= 128 + 640)
|
||||
this.adjust = this.add(new DragAdjust(width / 2 - 230, height - 64 - 640, 460, 640));
|
||||
else
|
||||
this.adjust = this.add(new DragAdjust(390 - 115 - 4, height - 32 - 160 - 4, 115, 160));
|
||||
|
||||
this.add(new Label(width - 396, 36, 392, 20, "Spezies: " + (this.gm.thePlayer == null ? "<?>" : this.gm.thePlayer.getSpecies().name), true));
|
||||
this.add(new NavButton(width - 396, 56, 392, 24, GuiSpecies.INSTANCE, "Spezies ändern"));
|
||||
this.add(new Label(width - 396, 36 + 92, 392, 20, "Klasse: " + (this.gm.thePlayer == null || this.gm.thePlayer.getSpecies().classEnum == null || this.gm.thePlayer.getNpcClass() == null || this.gm.thePlayer.getNpcClass().toString().isEmpty() ? "<Keine>" : this.gm.thePlayer.getNpcClass().toString()), true))
|
||||
.enabled = this.gm.thePlayer != null && this.gm.thePlayer.getSpecies().classEnum != null;
|
||||
this.add(new NavButton(width - 396, 56 + 92, 392, 24, GuiClass.INSTANCE, "Klasse ändern"))
|
||||
.enabled = this.gm.thePlayer != null && this.gm.thePlayer.getSpecies().classEnum != null;
|
||||
this.add(new Label(width - 390, 48, 388, "Spezies: " + (this.gm.player == null ? "<?>" : this.gm.player.getSpecies().name), true));
|
||||
this.add(new NavButton(width - 390, 48, 388, 0, GuiSpecies.INSTANCE, "Spezies ändern"));
|
||||
this.add(new Label(width - 390, 82, 388, "Klasse: " + (this.gm.player == null || this.gm.player.getSpecies().classEnum == null || this.gm.player.getNpcClass() == null || this.gm.player.getNpcClass().toString().isEmpty() ? "<Keine>" : this.gm.player.getNpcClass().toString()), true))
|
||||
.enabled = this.gm.player != null && this.gm.player.getSpecies().classEnum != null;
|
||||
this.add(new NavButton(width - 390, 82, 388, 0, GuiClass.INSTANCE, "Klasse ändern"))
|
||||
.enabled = this.gm.player != null && this.gm.player.getSpecies().classEnum != null;
|
||||
|
||||
final ActButton[] alignBtns = new ActButton[Alignment.values().length];
|
||||
for (int z = 0; z < Alignment.values().length; z++)
|
||||
{
|
||||
final Alignment align = Alignment.values()[z];
|
||||
alignBtns[z] = this.add(new ActButton(width - 396 + (z % 3) * 132, height - 32 - 28 * 3 + 28 * (z / 3), 128, 24, new ActButton.Callback() {
|
||||
public void use(ActButton elem, Mode action) {
|
||||
if(GuiChar.this.gm.thePlayer != null) {
|
||||
alignBtns[z] = this.add(new ActButton(width - 390 + (z % 3) * 130, height - 32 - 20 * 3 + 20 * (z / 3), 128, 0, new ButtonCallback() {
|
||||
public void use(ActButton elem, PressType action) {
|
||||
if(GuiChar.this.gm.player != null) {
|
||||
GuiChar.this.waiting = false;
|
||||
GuiChar.this.gm.thePlayer.sendQueue.addToSendQueue(new CPacketAction(CPacketAction.Action.SET_ALIGN, align.ordinal()));
|
||||
GuiChar.this.gm.player.client.addToSendQueue(new CPacketAction(CPacketAction.Action.SET_ALIGN, align.ordinal()));
|
||||
for(ActButton btn : alignBtns) {
|
||||
btn.enabled = btn != elem;
|
||||
}
|
||||
}
|
||||
}
|
||||
}, align.color + align.display));
|
||||
alignBtns[z].enabled = this.gm.thePlayer == null || this.gm.thePlayer.getAlignment() != align;
|
||||
alignBtns[z].enabled = this.gm.player == null || this.gm.player.getAlignment() != align;
|
||||
}
|
||||
this.add(new Slider(width / 2 - 200, height - 28, 400, 24, 1, this.gm.thePlayer == null ? 120 : this.gm.thePlayer.getMinSize(), this.gm.thePlayer == null ? 320 : this.gm.thePlayer.getMaxSize(), this.gm.thePlayer == null ? 180 : this.gm.thePlayer.getDefaultSize(), this.gm.thePlayer == null ? 180 : this.gm.thePlayer.getCurrentSize(), new Slider.Callback() {
|
||||
this.add(new Slider(width - 390, 136, 388, 0, 1, this.gm.player == null ? 120 : this.gm.player.getMinSize(), this.gm.player == null ? 320 : this.gm.player.getMaxSize(), this.gm.player == null ? 180 : this.gm.player.getDefaultSize(), this.gm.player == null ? 180 : this.gm.player.getCurrentSize(), new SliderCallback() {
|
||||
public void use(Slider elem, int value) {
|
||||
if(GuiChar.this.gm.thePlayer != null) {
|
||||
if(GuiChar.this.gm.player != null) {
|
||||
GuiChar.this.waiting = false;
|
||||
GuiChar.this.gm.thePlayer.sendQueue.addToSendQueue(new CPacketAction(CPacketAction.Action.SET_HEIGHT, value));
|
||||
GuiChar.this.gm.player.client.addToSendQueue(new CPacketAction(CPacketAction.Action.SET_HEIGHT, value));
|
||||
}
|
||||
}
|
||||
}, "Spieler-Größe", "cm")).enabled = this.gm.thePlayer == null || this.gm.thePlayer.getMinSize() != this.gm.thePlayer.getMaxSize();
|
||||
this.add(new Label(width / 2 - 200, 36, 400, 20, "Name", true));
|
||||
this.add(new Label(width - 396, height - 384, 392, 20, "Beschreibung", true));
|
||||
final Textbox descField = this.add(new Textbox(width - 396, height - 364, 392, 130, Player.MAX_INFO_LENGTH, new Textbox.Callback() {
|
||||
public void use(Textbox elem, Action value) {
|
||||
}
|
||||
}, ""));
|
||||
this.add(new ActButton(width - 198, height - 28, 194, 24, new ActButton.Callback() {
|
||||
public void use(ActButton elem, Mode action) {
|
||||
if(GuiChar.this.gm.thePlayer != null) {
|
||||
}, "Spieler-Größe", "cm")).enabled = this.gm.player == null || this.gm.player.getMinSize() != this.gm.player.getMaxSize();
|
||||
this.add(new Label(width - 390, 116, 388, "Name", true));
|
||||
this.add(new Label(width - 390, 170, 388, "Beschreibung", true));
|
||||
final Area descField = this.add(new Area(width - 390, 170, 388, height - 328, IPlayer.MAX_INFO_LENGTH, ""));
|
||||
this.add(new ActButton(width - 195, height - 30, 193, 0, new ButtonCallback() {
|
||||
public void use(ActButton elem, PressType action) {
|
||||
if(GuiChar.this.gm.player != null) {
|
||||
GuiChar.this.gm.displayGuiScreen(GuiLoading.makeWaitTask("Lade Welt ..."));
|
||||
Dimension dim = UniverseRegistry.getBaseDimensions().get(GuiChar.this.dimension);
|
||||
GuiChar.this.gm.thePlayer.sendQueue.addToSendQueue(new CPacketMessage(CPacketMessage.Type.INFO, descField.getText()));
|
||||
GuiChar.this.gm.thePlayer.sendQueue.addToSendQueue(new CPacketAction(CPacketAction.Action.CLOSE_EDITOR, dim.getDimensionId()));
|
||||
GuiChar.this.gm.player.client.addToSendQueue(new CPacketMessage(CPacketMessage.Type.INFO, descField.getText()));
|
||||
GuiChar.this.gm.player.client.addToSendQueue(new CPacketAction(CPacketAction.Action.CLOSE_EDITOR, dim.getDimensionId()));
|
||||
}
|
||||
}
|
||||
}, "Charakter erstellen"));
|
||||
this.add(new Textbox(width / 2 - 200, 36 + 20, 400, 24, Player.MAX_NICK_LENGTH, true, new Textbox.Callback() {
|
||||
public void use(Textbox elem, Action value) {
|
||||
if(value == Action.SEND || value == Action.UNFOCUS) {
|
||||
this.cancelButton = this.add(new ActButton(width - 390, height - 30, 193, 0, new ButtonCallback() {
|
||||
public void use(ActButton elem, PressType action) {
|
||||
if(GuiChar.this.gm.player != null)
|
||||
GuiChar.this.gm.displayGuiScreen(GuiCharacters.INSTANCE);
|
||||
}
|
||||
}, "Abbrechen"));
|
||||
this.setCharsAvailable();
|
||||
this.add(new Field(width - 390, 116, 388, 0, IPlayer.MAX_NICK_LENGTH, new FieldCallback() {
|
||||
public void use(Field elem, FieldAction value) {
|
||||
if(value == FieldAction.SEND || value == FieldAction.UNFOCUS) {
|
||||
String name = elem.getText();
|
||||
if(name.isEmpty())
|
||||
elem.setText(GuiChar.this.gm.thePlayer == null ? "..." : GuiChar.this.gm.thePlayer.getCustomNameTag());
|
||||
else if(GuiChar.this.gm.thePlayer != null) {
|
||||
elem.setText(GuiChar.this.gm.player == null ? "..." : GuiChar.this.gm.player.getCustomNameTag());
|
||||
else if(GuiChar.this.gm.player != null) {
|
||||
GuiChar.this.waiting = false;
|
||||
GuiChar.this.gm.thePlayer.sendQueue.addToSendQueue(new CPacketMessage(CPacketMessage.Type.DISPLAY, name));
|
||||
GuiChar.this.gm.player.client.addToSendQueue(new CPacketMessage(CPacketMessage.Type.DISPLAY, name));
|
||||
}
|
||||
}
|
||||
}
|
||||
}, Player.VALID_NICK, this.gm.thePlayer == null ? "" : this.gm.thePlayer.getCustomNameTag()));
|
||||
}, IPlayer.VALID_NICK, this.gm.player == null ? "" : this.gm.player.getCustomNameTag()));
|
||||
this.templateButton.enabled = false;
|
||||
this.dimension = new Random().zrange(UniverseRegistry.getBaseDimensions().size());
|
||||
EntityEggInfo egg = EntityRegistry.SPAWN_EGGS.get(this.gm.thePlayer == null ? EntityRegistry.getEntityString(EntityHuman.class) : EntityRegistry.getEntityString(this.gm.thePlayer));
|
||||
if(egg != null && egg.origin != null) {
|
||||
Dimension dim = UniverseRegistry.getDimension(egg.origin);
|
||||
EntityInfo egg = EntityRegistry.SPAWN_EGGS.get(this.gm.player == null ? EntityRegistry.getEntityString(EntityHuman.class) : EntityRegistry.getEntityString(this.gm.player));
|
||||
if(egg != null && egg.origin() != null) {
|
||||
Dimension dim = UniverseRegistry.getDimension(egg.origin());
|
||||
if(dim != null) {
|
||||
for(int z = 0; z < UniverseRegistry.getBaseDimensions().size(); z++) {
|
||||
if(UniverseRegistry.getBaseDimensions().get(z).getDimensionId() == dim.getDimensionId()) {
|
||||
|
@ -401,12 +423,12 @@ public class GuiChar extends GuiList<GuiChar.SkinEntry>
|
|||
}
|
||||
}
|
||||
}
|
||||
this.dimButton = this.add(new ActButton(width - 396, height - 220, 392, 24, new ActButton.Callback() {
|
||||
public void use(ActButton elem, Mode mode) {
|
||||
if(mode == Mode.TERTIARY) {
|
||||
this.dimButton = this.add(new ActButton(width - 390, height - 156, 388, 0, new ButtonCallback() {
|
||||
public void use(ActButton elem, PressType mode) {
|
||||
if(mode == PressType.TERTIARY) {
|
||||
GuiChar.this.dimension = new Random().zrange(UniverseRegistry.getBaseDimensions().size());
|
||||
}
|
||||
else if(mode == Mode.SECONDARY) {
|
||||
else if(mode == PressType.SECONDARY) {
|
||||
if(--GuiChar.this.dimension < 0)
|
||||
GuiChar.this.dimension = UniverseRegistry.getBaseDimensions().size() - 1;
|
||||
}
|
||||
|
@ -417,7 +439,7 @@ public class GuiChar extends GuiList<GuiChar.SkinEntry>
|
|||
GuiChar.this.setDimButton();
|
||||
}
|
||||
}, ""));
|
||||
this.descLines = this.add(new TransparentBox(width - 396, height - 220 + 24, 392, 66, "", false));
|
||||
this.descLines = this.add(new MultiLabel(width - 390, height - 156 + Element.BASE_HEIGHT, 388, 42, "", true));
|
||||
this.setDimButton();
|
||||
}
|
||||
|
||||
|
@ -437,10 +459,12 @@ public class GuiChar extends GuiList<GuiChar.SkinEntry>
|
|||
public void drawOverlays()
|
||||
{
|
||||
if(this.adjust != null) {
|
||||
float factor = this.gm.thePlayer.width > 2.15f ? 2.15f / this.gm.thePlayer.width : 1.0f;
|
||||
factor = this.gm.thePlayer.height > 3.0f && 3.0f / this.gm.thePlayer.height < factor ? 3.0f / this.gm.thePlayer.height : factor;
|
||||
drawEntity(400 + (this.gm.fb_x - 400 - 400) / 2, this.gm.fb_y - 160, 160.0f * factor
|
||||
, this.yaw, this.pitch, this.gm.thePlayer);
|
||||
float factor = this.gm.player.width > 2.15f ? 2.15f / this.gm.player.width : 1.0f;
|
||||
factor = this.gm.player.height > 3.0f && 3.0f / this.gm.player.height < factor ? 3.0f / this.gm.player.height : factor;
|
||||
if(this.gm.fb_x >= 784 + 460 && this.gm.fb_y >= 128 + 640)
|
||||
drawEntity(400 + (this.gm.fb_x - 400 - 400) / 2, this.gm.fb_y - 160, 160.0f * factor, this.yaw, this.pitch, this.gm.player);
|
||||
else
|
||||
drawEntity(390 - 4 - 115 / 2, this.gm.fb_y - 60, 40.0f * factor, this.yaw, this.pitch, this.gm.player);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -460,6 +484,11 @@ public class GuiChar extends GuiList<GuiChar.SkinEntry>
|
|||
return "Charakter anpassen";
|
||||
}
|
||||
|
||||
public void setCharsAvailable() {
|
||||
if(this.cancelButton != null)
|
||||
this.cancelButton.enabled = !this.gm.characterList.isEmpty();
|
||||
}
|
||||
|
||||
public static BufferedImage loadSkin(File file)
|
||||
{
|
||||
BufferedImage img = null;
|
||||
|
@ -528,11 +557,6 @@ public class GuiChar extends GuiList<GuiChar.SkinEntry>
|
|||
this.elements.clear();
|
||||
}
|
||||
|
||||
public int getListWidth()
|
||||
{
|
||||
return 400 - 20;
|
||||
}
|
||||
|
||||
public int getSlotHeight()
|
||||
{
|
||||
return 64 + 4;
|
||||
|
@ -604,7 +628,7 @@ public class GuiChar extends GuiList<GuiChar.SkinEntry>
|
|||
ent.headYaw = ent.rotYaw;
|
||||
ent.prevHeadYaw = ent.rotYaw;
|
||||
GL11.glTranslatef(0.0F, -(ent.height / 2), 0.0F);
|
||||
RenderManager rendermanager = Game.getGame().getRenderManager();
|
||||
RenderManager rendermanager = Client.CLIENT.getRenderManager();
|
||||
rendermanager.setPlayerViewY(180.0F);
|
||||
rendermanager.renderEntity(ent, 0.0D, 0.0D, 0.0D, 1.0F);
|
||||
// GL11.glTranslatef(0.0F, 0.0F, 0.0F);
|
120
client/src/main/java/client/gui/character/GuiCharacters.java
Normal file
120
client/src/main/java/client/gui/character/GuiCharacters.java
Normal file
|
@ -0,0 +1,120 @@
|
|||
package client.gui.character;
|
||||
|
||||
import client.gui.Font;
|
||||
import client.gui.GuiConfirm;
|
||||
import client.gui.GuiMenu;
|
||||
import client.gui.element.ActButton;
|
||||
import client.gui.element.Area;
|
||||
import client.gui.element.ButtonCallback;
|
||||
import client.gui.element.GuiList;
|
||||
import client.gui.element.ListEntry;
|
||||
import client.gui.element.NavButton;
|
||||
import client.gui.element.PressType;
|
||||
import client.renderer.Drawing;
|
||||
import common.color.TextColor;
|
||||
import common.entity.npc.PlayerCharacter;
|
||||
import common.packet.CPacketAction;
|
||||
import common.packet.CPacketAction.Action;
|
||||
import common.util.ExtMath;
|
||||
|
||||
public class GuiCharacters extends GuiList<GuiCharacters.CharacterEntry> implements ButtonCallback
|
||||
{
|
||||
protected class CharacterEntry implements ListEntry
|
||||
{
|
||||
private final PlayerCharacter character;
|
||||
private final boolean initial;
|
||||
|
||||
protected CharacterEntry(PlayerCharacter character, boolean initial)
|
||||
{
|
||||
this.character = character;
|
||||
this.initial = initial;
|
||||
}
|
||||
|
||||
public void draw(int x, int y, int width, int height, int mouseX, int mouseY, boolean hovered)
|
||||
{
|
||||
if(this.initial)
|
||||
Drawing.drawRect(x, y, 1, 36, 0xffaf0000);
|
||||
String str = this.character == null ? TextColor.BLUE + "[" + TextColor.CYAN + "+" + TextColor.BLUE + "]" :
|
||||
String.format(TextColor.GREEN + "Level " + TextColor.DGREEN + "%d " + TextColor.YELLOW + "%s " + TextColor.VIOLET + "%s",
|
||||
character.level(), character.type(), character.name());
|
||||
String pos = this.character == null ? TextColor.BROWN + "Neuen Charakter erstellen" :
|
||||
String.format(TextColor.NEON + "%s " + TextColor.GRAY + "bei " + TextColor.ACID + "%d" + TextColor.GRAY + ", " + TextColor.ACID + "%d" + TextColor.GRAY + ", " + TextColor.ACID + "%d",
|
||||
character.dim(), character.pos().getX(), character.pos().getY(), character.pos().getZ());
|
||||
Drawing.drawText(str, x + 3, y, 0xffffffff);
|
||||
Drawing.drawText(pos, x + 3, y + height - Font.YGLYPH, 0xffffffff);
|
||||
}
|
||||
|
||||
public void select(boolean dclick, int mx, int my)
|
||||
{
|
||||
if(dclick)
|
||||
GuiCharacters.this.use(GuiCharacters.this.actionButtom, PressType.PRIMARY);
|
||||
GuiCharacters.this.updateButtons();
|
||||
}
|
||||
}
|
||||
|
||||
public static final GuiCharacters INSTANCE = new GuiCharacters();
|
||||
|
||||
private Area descField;
|
||||
private ActButton actionButtom;
|
||||
private ActButton deleteButtom;
|
||||
|
||||
private GuiCharacters() {
|
||||
}
|
||||
|
||||
private void updateButtons() {
|
||||
CharacterEntry entry = this.getSelected();
|
||||
this.descField.setText(entry == null ? "" : (entry.character == null ? "*neuer Charakter*" : String.format(TextColor.GRAY + "[%s%s" + TextColor.GRAY + "]\n" + TextColor.RESET + "%s", entry.character.align().color, entry.character.align().display, entry.character.info() == null ? "*keine Beschreibung vorhanden*" : this.getSelected().character.info())));
|
||||
this.actionButtom.setText(entry != null && entry.character == null ? "Charakter erstellen" : "Charakter spielen");
|
||||
this.actionButtom.enabled = entry != null && !entry.initial;
|
||||
this.deleteButtom.enabled = !this.gm.charEditor && entry != null && entry.character != null && !entry.initial;
|
||||
}
|
||||
|
||||
public void init(int width, int height)
|
||||
{
|
||||
super.init(width, height);
|
||||
this.setDimensions(width - 300, height, 32, height - 32);
|
||||
this.elements.clear();
|
||||
int selected = this.gm.selectedCharacter;
|
||||
for(PlayerCharacter character : this.gm.characterList) {
|
||||
this.elements.add(new CharacterEntry(selected == this.elements.size() ? new PlayerCharacter(character.name(), character.info(), character.align(), this.gm.player.worldObj.dimension.getFormattedName(false), this.gm.player.getPosition(), character.type(), this.gm.player.experienceLevel) : character, selected == this.elements.size()));
|
||||
}
|
||||
if(!this.gm.charEditor)
|
||||
this.elements.add(new CharacterEntry(null, false));
|
||||
this.setSelected(ExtMath.clampi(selected, -1, this.elements.size() - 1));
|
||||
this.descField = this.add(new Area(width - 300, 32, 300, height - 64, ""));
|
||||
this.deleteButtom = this.add(new ActButton(width / 2 - 302, height - 30, 200, 0, this, "Charakter löschen"));
|
||||
this.actionButtom = this.add(new ActButton(width / 2 - 100, height - 30, 200, 0, this, ""));
|
||||
this.add(new NavButton(width / 2 + 102, height - 30, 200, 0, this.gm.charEditor ? GuiChar.INSTANCE : GuiMenu.INSTANCE, this.gm.charEditor ? "Zurück" : "Abbrechen"));
|
||||
this.updateButtons();
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return "Charakter auswählen";
|
||||
}
|
||||
|
||||
public int getSlotHeight()
|
||||
{
|
||||
return 36 + 4;
|
||||
}
|
||||
|
||||
public void use(ActButton elem, PressType action) {
|
||||
CharacterEntry entry = GuiCharacters.this.getSelected();
|
||||
if(entry != null && GuiCharacters.this.gm.getNetHandler() != null) {
|
||||
if(elem == this.actionButtom) {
|
||||
if(entry.character == null)
|
||||
this.gm.getNetHandler().addToSendQueue(new CPacketAction(CPacketAction.Action.OPEN_EDITOR));
|
||||
else
|
||||
this.gm.getNetHandler().addToSendQueue(new CPacketAction(GuiCharacters.this.gm.charEditor ? Action.CANCEL_EDITOR : CPacketAction.Action.SELECT_CHARACTER, this.selectedElement));
|
||||
}
|
||||
else if(elem == this.deleteButtom && entry.character != null) {
|
||||
this.gm.displayGuiScreen(new GuiConfirm(new GuiConfirm.Callback() {
|
||||
public void confirm(boolean confirmed) {
|
||||
if(confirmed)
|
||||
GuiCharacters.this.gm.getNetHandler().addToSendQueue(new CPacketAction(CPacketAction.Action.DELETE_CHARACTER, GuiCharacters.this.selectedElement));
|
||||
GuiCharacters.this.gm.displayGuiScreen(GuiCharacters.this);
|
||||
}
|
||||
}, "Möchtest du diesen Charakter wirklich löschen?", "Der Fortschritt, die Gegenstände und die Historie\nvon \"" + entry.character.name() + "\" werden für immer verloren sein!", "Löschen", "Abbrechen"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
73
client/src/main/java/client/gui/character/GuiClass.java
Normal file
73
client/src/main/java/client/gui/character/GuiClass.java
Normal file
|
@ -0,0 +1,73 @@
|
|||
package client.gui.character;
|
||||
|
||||
import client.gui.element.ActButton;
|
||||
import client.gui.element.ButtonCallback;
|
||||
import client.gui.element.GuiList;
|
||||
import client.gui.element.ListEntry;
|
||||
import client.gui.element.NavButton;
|
||||
import client.gui.element.PressType;
|
||||
import client.renderer.Drawing;
|
||||
import common.packet.CPacketAction;
|
||||
|
||||
public class GuiClass extends GuiList<GuiClass.ClassEntry> implements ButtonCallback
|
||||
{
|
||||
protected class ClassEntry implements ListEntry
|
||||
{
|
||||
private final Enum clazz;
|
||||
|
||||
protected ClassEntry(Enum clazz)
|
||||
{
|
||||
this.clazz = clazz;
|
||||
}
|
||||
|
||||
public void draw(int x, int y, int width, int height, int mouseX, int mouseY, boolean hovered)
|
||||
{
|
||||
if(GuiClass.this.gm.player != null && this.clazz == GuiClass.this.gm.player.getNpcClass())
|
||||
Drawing.drawRect(x, y, 1, 44, 0xffaf0000);
|
||||
Drawing.drawText(this.clazz.toString().isEmpty() ? "<Keine>" : this.clazz.toString(), x + 3, y, 0xffffffff);
|
||||
}
|
||||
|
||||
public void select(boolean dclick, int mx, int my)
|
||||
{
|
||||
if((GuiClass.this.selectButton.enabled = GuiClass.this.gm.player == null || this.clazz != GuiClass.this.gm.player.getNpcClass()) && dclick)
|
||||
GuiClass.this.use(GuiClass.this.selectButton, PressType.PRIMARY);
|
||||
}
|
||||
}
|
||||
|
||||
public static final GuiClass INSTANCE = new GuiClass();
|
||||
|
||||
private ActButton selectButton;
|
||||
|
||||
private GuiClass() {
|
||||
}
|
||||
|
||||
public void init(int width, int height)
|
||||
{
|
||||
super.init(width, height);
|
||||
this.setDimensions(width, height, 32, height - 32);
|
||||
this.elements.clear();
|
||||
if(this.gm.player != null && this.gm.player.getSpecies().classEnum != null)
|
||||
for(Enum clazz : this.gm.player.getSpecies().classEnum.getEnumConstants()) {
|
||||
this.elements.add(new ClassEntry(clazz));
|
||||
}
|
||||
this.add(new NavButton(width / 2 - 195, height - 30, 194, 0, GuiChar.INSTANCE, "Zurück"));
|
||||
this.selectButton = this.add(new ActButton(width / 2 + 1, height - 30, 194, 0, this, "Klasse ändern"));
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return "Klasse wählen";
|
||||
}
|
||||
|
||||
public int getSlotHeight()
|
||||
{
|
||||
return 44 + 4;
|
||||
}
|
||||
|
||||
public void use(ActButton elem, PressType action) {
|
||||
ClassEntry entry = this.getSelected();
|
||||
if(entry != null && GuiClass.this.gm.player != null) {
|
||||
GuiClass.this.gm.player.client.addToSendQueue(new CPacketAction(CPacketAction.Action.SET_CLASS, entry.clazz.ordinal()));
|
||||
this.gm.displayGuiScreen(GuiChar.INSTANCE);
|
||||
}
|
||||
}
|
||||
}
|
75
client/src/main/java/client/gui/character/GuiSpecies.java
Normal file
75
client/src/main/java/client/gui/character/GuiSpecies.java
Normal file
|
@ -0,0 +1,75 @@
|
|||
package client.gui.character;
|
||||
|
||||
import client.gui.element.ActButton;
|
||||
import client.gui.element.ButtonCallback;
|
||||
import client.gui.element.GuiList;
|
||||
import client.gui.element.ListEntry;
|
||||
import client.gui.element.NavButton;
|
||||
import client.gui.element.PressType;
|
||||
import client.renderer.Drawing;
|
||||
import common.entity.npc.SpeciesInfo;
|
||||
import common.init.EntityRegistry;
|
||||
import common.init.SpeciesRegistry;
|
||||
import common.packet.CPacketAction;
|
||||
|
||||
public class GuiSpecies extends GuiList<GuiSpecies.SpeciesEntry> implements ButtonCallback
|
||||
{
|
||||
protected class SpeciesEntry implements ListEntry
|
||||
{
|
||||
private final SpeciesInfo species;
|
||||
|
||||
protected SpeciesEntry(SpeciesInfo species)
|
||||
{
|
||||
this.species = species;
|
||||
}
|
||||
|
||||
public void draw(int x, int y, int width, int height, int mouseX, int mouseY, boolean hovered)
|
||||
{
|
||||
if(GuiSpecies.this.gm.player != null && this.species == GuiSpecies.this.gm.player.getSpecies())
|
||||
Drawing.drawRect(x, y, 1, 44, 0xffaf0000);
|
||||
Drawing.drawText(this.species.name, x + 3, y, 0xff000000 | this.species.color1 | this.species.color2);
|
||||
if(this.species.classEnum != null)
|
||||
Drawing.drawText(this.species.classEnum.getEnumConstants().length + " Klassen", x + 3, y + 18, 0xffc0c0c0);
|
||||
}
|
||||
|
||||
public void select(boolean dclick, int mx, int my)
|
||||
{
|
||||
if((GuiSpecies.this.selectButton.enabled = GuiSpecies.this.gm.player == null || this.species != GuiSpecies.this.gm.player.getSpecies()) && dclick)
|
||||
GuiSpecies.this.use(GuiSpecies.this.selectButton, PressType.PRIMARY);
|
||||
}
|
||||
}
|
||||
|
||||
public static final GuiSpecies INSTANCE = new GuiSpecies();
|
||||
|
||||
private ActButton selectButton;
|
||||
|
||||
private GuiSpecies() {
|
||||
}
|
||||
|
||||
public void init(int width, int height)
|
||||
{
|
||||
super.init(width, height);
|
||||
this.setDimensions(width, height, 32, height - 32);
|
||||
this.elements.clear();
|
||||
for(SpeciesInfo species : SpeciesRegistry.SPECIMEN) {
|
||||
this.elements.add(new SpeciesEntry(species));
|
||||
}
|
||||
this.add(new NavButton(width / 2 - 195, height - 30, 194, 0, GuiChar.INSTANCE, "Zurück"));
|
||||
this.selectButton = this.add(new ActButton(width / 2 + 1, height - 30, 194, 0, this, "Spezies ändern"));
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return "Spezies wählen";
|
||||
}
|
||||
|
||||
public int getSlotHeight()
|
||||
{
|
||||
return 44 + 4;
|
||||
}
|
||||
|
||||
public void use(ActButton elem, PressType action) {
|
||||
SpeciesEntry entry = this.getSelected();
|
||||
if(entry != null && GuiSpecies.this.gm.player != null)
|
||||
GuiSpecies.this.gm.player.client.addToSendQueue(new CPacketAction(CPacketAction.Action.SET_SPECIES, EntityRegistry.getEntityID(entry.species.clazz)));
|
||||
}
|
||||
}
|
|
@ -1,8 +1,8 @@
|
|||
package game.gui.container;
|
||||
package client.gui.container;
|
||||
|
||||
import game.inventory.ContainerBrewingStand;
|
||||
import game.inventory.IInventory;
|
||||
import game.inventory.InventoryPlayer;
|
||||
import common.inventory.ContainerBrewingStand;
|
||||
import common.inventory.IInventory;
|
||||
import common.inventory.InventoryPlayer;
|
||||
|
||||
|
||||
public class GuiBrewing extends GuiContainer
|
|
@ -1,8 +1,8 @@
|
|||
package game.gui.container;
|
||||
package client.gui.container;
|
||||
|
||||
import game.Game;
|
||||
import game.inventory.ContainerChest;
|
||||
import game.inventory.IInventory;
|
||||
import client.Client;
|
||||
import common.inventory.ContainerChest;
|
||||
import common.inventory.IInventory;
|
||||
|
||||
|
||||
public class GuiChest extends GuiContainer
|
||||
|
@ -19,7 +19,7 @@ public class GuiChest extends GuiContainer
|
|||
|
||||
public GuiChest(IInventory upperInv, IInventory lowerInv)
|
||||
{
|
||||
super(new ContainerChest(upperInv, lowerInv, Game.getGame().thePlayer));
|
||||
super(new ContainerChest(upperInv, lowerInv, Client.CLIENT.player));
|
||||
this.upperChestInventory = upperInv;
|
||||
this.lowerChestInventory = lowerInv;
|
||||
// this.allowUserInput = false;
|
|
@ -1,4 +1,4 @@
|
|||
package game.gui.container;
|
||||
package client.gui.container;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
@ -6,24 +6,24 @@ import java.util.Set;
|
|||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.opengl.GL13;
|
||||
|
||||
import game.collect.Lists;
|
||||
import game.collect.Sets;
|
||||
|
||||
import game.color.TextColor;
|
||||
import game.gui.Gui;
|
||||
import game.gui.element.InventoryButton;
|
||||
import game.inventory.Container;
|
||||
import game.inventory.InventoryPlayer;
|
||||
import game.inventory.Slot;
|
||||
import game.item.CheatTab;
|
||||
import game.item.ItemStack;
|
||||
import game.packet.CPacketCheat;
|
||||
import game.renderer.Drawing;
|
||||
import game.renderer.GlState;
|
||||
import game.renderer.ItemRenderer;
|
||||
import game.renderer.entity.RenderItem;
|
||||
import game.util.ExtMath;
|
||||
import game.window.Button;
|
||||
import client.gui.Font;
|
||||
import client.gui.Gui;
|
||||
import client.gui.element.InventoryButton;
|
||||
import client.renderer.Drawing;
|
||||
import client.renderer.GlState;
|
||||
import client.renderer.ItemRenderer;
|
||||
import client.renderer.entity.RenderItem;
|
||||
import client.window.Button;
|
||||
import common.collect.Lists;
|
||||
import common.collect.Sets;
|
||||
import common.color.TextColor;
|
||||
import common.inventory.Container;
|
||||
import common.inventory.InventoryPlayer;
|
||||
import common.inventory.Slot;
|
||||
import common.item.CheatTab;
|
||||
import common.item.ItemStack;
|
||||
import common.packet.CPacketCheat;
|
||||
import common.util.ExtMath;
|
||||
|
||||
public abstract class GuiContainer extends Gui
|
||||
{
|
||||
|
@ -43,7 +43,7 @@ public abstract class GuiContainer extends Gui
|
|||
|
||||
private static final List<ItemStack> ITEM_LIST = Lists.<ItemStack>newArrayList();
|
||||
|
||||
private static CheatTab selectedTab = CheatTab.tabBlocks;
|
||||
private static CheatTab selectedTab = CheatTab.BLOCKS;
|
||||
// /** The location of the inventory background texture */
|
||||
// protected static final String inventoryBackground = "textures/gui/inventory.png";
|
||||
|
||||
|
@ -214,7 +214,7 @@ public abstract class GuiContainer extends Gui
|
|||
*/
|
||||
public void initGui()
|
||||
{
|
||||
this.gm.thePlayer.openContainer = this.inventorySlots;
|
||||
this.gm.player.openContainer = this.inventorySlots;
|
||||
// this.guiLeft = (this.width - this.xSize) / 2;
|
||||
// this.guiTop = (this.height - this.ySize) / 2;
|
||||
// this.addButtons();
|
||||
|
@ -361,7 +361,7 @@ public abstract class GuiContainer extends Gui
|
|||
ItemRenderer.disableStandardItemLighting();
|
||||
// this.drawGuiContainerForegroundLayer(mouseX, mouseY);
|
||||
ItemRenderer.enableGUIStandardItemLighting();
|
||||
InventoryPlayer inventoryplayer = this.gm.thePlayer.inventory;
|
||||
InventoryPlayer inventoryplayer = this.gm.player.inventory;
|
||||
ItemStack itemstack = this.draggedStack == null ? inventoryplayer.getItemStack() : this.draggedStack;
|
||||
if(this.gm.itemCheat)
|
||||
itemstack = itemstack == null ? this.cheatStack : itemstack;
|
||||
|
@ -375,20 +375,20 @@ public abstract class GuiContainer extends Gui
|
|||
if (this.draggedStack != null && this.isRightMouseClick)
|
||||
{
|
||||
itemstack = itemstack.copy();
|
||||
itemstack.stackSize = ExtMath.ceilf((float)itemstack.stackSize / 2.0F);
|
||||
itemstack.size = ExtMath.ceilf((float)itemstack.size / 2.0F);
|
||||
}
|
||||
else if (this.dragSplitting && this.dragSplittingSlots.size() > 1)
|
||||
{
|
||||
itemstack = itemstack.copy();
|
||||
itemstack.stackSize = this.dragSplittingRemnant;
|
||||
itemstack.size = this.dragSplittingRemnant;
|
||||
|
||||
if (itemstack.stackSize == 0)
|
||||
if (itemstack.size == 0)
|
||||
{
|
||||
s = "" + TextColor.YELLOW + "0";
|
||||
}
|
||||
}
|
||||
else if(itemstack == this.cheatStack) {
|
||||
s = TextColor.DGREEN + "+" + TextColor.GREEN + ItemStack.formatAmount(itemstack.stackSize);
|
||||
s = TextColor.DGREEN + "+" + TextColor.GREEN + ItemStack.formatAmount(itemstack.size);
|
||||
}
|
||||
|
||||
this.drawItemStack(itemstack, mouseX - j2, mouseY - k2, s);
|
||||
|
@ -452,7 +452,7 @@ public abstract class GuiContainer extends Gui
|
|||
}
|
||||
|
||||
protected void renderToolTip(ItemStack stack, int x, int y) {
|
||||
List<String> list = stack.getTooltip(this.gm.thePlayer);
|
||||
List<String> list = stack.getTooltip(this.gm.player);
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for(int i = 0; i < list.size(); ++i) {
|
||||
if(i != 0)
|
||||
|
@ -513,13 +513,13 @@ public abstract class GuiContainer extends Gui
|
|||
ItemStack itemstack = slotIn.getStack();
|
||||
boolean flag = false;
|
||||
boolean flag1 = slotIn == this.clickedSlot && this.draggedStack != null && !this.isRightMouseClick;
|
||||
ItemStack itemstack1 = this.gm.thePlayer.inventory.getItemStack();
|
||||
ItemStack itemstack1 = this.gm.player.inventory.getItemStack();
|
||||
String s = null;
|
||||
|
||||
if (slotIn == this.clickedSlot && this.draggedStack != null && this.isRightMouseClick && itemstack != null)
|
||||
{
|
||||
itemstack = itemstack.copy();
|
||||
itemstack.stackSize /= 2;
|
||||
itemstack.size /= 2;
|
||||
}
|
||||
else if (this.dragSplitting && this.dragSplittingSlots.contains(slotIn) && itemstack1 != null)
|
||||
{
|
||||
|
@ -532,18 +532,18 @@ public abstract class GuiContainer extends Gui
|
|||
{
|
||||
itemstack = itemstack1.copy();
|
||||
flag = true;
|
||||
Container.computeStackSize(this.dragSplittingSlots, this.dragSplittingLimit, itemstack, slotIn.getStack() == null ? 0 : slotIn.getStack().stackSize);
|
||||
Container.computeStackSize(this.dragSplittingSlots, this.dragSplittingLimit, itemstack, slotIn.getStack() == null ? 0 : slotIn.getStack().size);
|
||||
|
||||
if (itemstack.stackSize > itemstack.getMaxStackSize())
|
||||
if (itemstack.size > itemstack.getMaxStackSize())
|
||||
{
|
||||
s = TextColor.YELLOW + ItemStack.formatAmount(itemstack.getMaxStackSize());
|
||||
itemstack.stackSize = itemstack.getMaxStackSize();
|
||||
itemstack.size = itemstack.getMaxStackSize();
|
||||
}
|
||||
|
||||
if (itemstack.stackSize > slotIn.getItemStackLimit(itemstack))
|
||||
if (itemstack.size > slotIn.getItemStackLimit(itemstack))
|
||||
{
|
||||
s = TextColor.YELLOW + ItemStack.formatAmount(slotIn.getItemStackLimit(itemstack));
|
||||
itemstack.stackSize = slotIn.getItemStackLimit(itemstack);
|
||||
itemstack.size = slotIn.getItemStackLimit(itemstack);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -590,29 +590,29 @@ public abstract class GuiContainer extends Gui
|
|||
|
||||
private void updateDragSplitting()
|
||||
{
|
||||
ItemStack itemstack = this.gm.thePlayer.inventory.getItemStack();
|
||||
ItemStack itemstack = this.gm.player.inventory.getItemStack();
|
||||
|
||||
if (itemstack != null && this.dragSplitting)
|
||||
{
|
||||
this.dragSplittingRemnant = itemstack.stackSize;
|
||||
this.dragSplittingRemnant = itemstack.size;
|
||||
|
||||
for (Slot slot : this.dragSplittingSlots)
|
||||
{
|
||||
ItemStack itemstack1 = itemstack.copy();
|
||||
int i = slot.getStack() == null ? 0 : slot.getStack().stackSize;
|
||||
int i = slot.getStack() == null ? 0 : slot.getStack().size;
|
||||
Container.computeStackSize(this.dragSplittingSlots, this.dragSplittingLimit, itemstack1, i);
|
||||
|
||||
if (itemstack1.stackSize > itemstack1.getMaxStackSize())
|
||||
if (itemstack1.size > itemstack1.getMaxStackSize())
|
||||
{
|
||||
itemstack1.stackSize = itemstack1.getMaxStackSize();
|
||||
itemstack1.size = itemstack1.getMaxStackSize();
|
||||
}
|
||||
|
||||
if (itemstack1.stackSize > slot.getItemStackLimit(itemstack1))
|
||||
if (itemstack1.size > slot.getItemStackLimit(itemstack1))
|
||||
{
|
||||
itemstack1.stackSize = slot.getItemStackLimit(itemstack1);
|
||||
itemstack1.size = slot.getItemStackLimit(itemstack1);
|
||||
}
|
||||
|
||||
this.dragSplittingRemnant -= itemstack1.stackSize - i;
|
||||
this.dragSplittingRemnant -= itemstack1.size - i;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -644,8 +644,8 @@ public abstract class GuiContainer extends Gui
|
|||
return;
|
||||
if(this.cheatStack != null) {
|
||||
Slot slot = this.getSlotAtPosition(mouseX, mouseY);
|
||||
if((mouseButton == 0 || mouseButton == 1) && slot != null && this.gm.thePlayer != null && slot.inventory == this.gm.thePlayer.inventory)
|
||||
this.gm.thePlayer.sendQueue.addToSendQueue(new CPacketCheat(this.cheatStack, slot.getIndex(), mouseButton == 0 && this.cheatStack.stackSize > 1));
|
||||
if((mouseButton == 0 || mouseButton == 1) && slot != null && this.gm.player != null && slot.inventory == this.gm.player.inventory)
|
||||
this.gm.player.client.addToSendQueue(new CPacketCheat(this.cheatStack, slot.getIndex(), mouseButton == 0 && this.cheatStack.size > 1));
|
||||
if(mouseButton != 1 && !this.gm.ctrl())
|
||||
this.cheatStack = null;
|
||||
return;
|
||||
|
@ -653,7 +653,7 @@ public abstract class GuiContainer extends Gui
|
|||
if((mouseButton == 0 || mouseButton == 1 || mouseButton == 2) && this.clickSide(mouseX, mouseY, -1, this.gm.shift() || mouseButton == 1, this.gm.ctrl() || mouseButton == 2))
|
||||
return;
|
||||
if(mouseButton == 0) {
|
||||
if(this.gm.itemCheat && this.gm.thePlayer != null && this.gm.thePlayer.inventory.getItemStack() == null) {
|
||||
if(this.gm.itemCheat && this.gm.player != null && this.gm.player.inventory.getItemStack() == null) {
|
||||
for (CheatTab tab : CheatTab.values())
|
||||
{
|
||||
if (this.isInsideTab(tab, mouseX, mouseY))
|
||||
|
@ -712,7 +712,7 @@ public abstract class GuiContainer extends Gui
|
|||
// else
|
||||
if (!this.dragSplitting)
|
||||
{
|
||||
if (this.gm.thePlayer.inventory.getItemStack() == null)
|
||||
if (this.gm.player.inventory.getItemStack() == null)
|
||||
{
|
||||
// if (mouseButton == this.gm.bindTertiary.getKeyCode() + 100)
|
||||
// {
|
||||
|
@ -775,7 +775,7 @@ public abstract class GuiContainer extends Gui
|
|||
if(this.gm == null || this.cheatStack != null)
|
||||
return;
|
||||
Slot slot = this.getSlotAtPosition(mouseX, mouseY);
|
||||
ItemStack itemstack = this.gm.thePlayer.inventory.getItemStack();
|
||||
ItemStack itemstack = this.gm.player.inventory.getItemStack();
|
||||
|
||||
// if (this.clickedSlot != null && this.gm.touchscreen)
|
||||
// {
|
||||
|
@ -812,7 +812,7 @@ public abstract class GuiContainer extends Gui
|
|||
// }
|
||||
// }
|
||||
// else
|
||||
if (this.dragSplitting && slot != null && itemstack != null && itemstack.stackSize > this.dragSplittingSlots.size() && Container.canAddItemToSlot(slot, itemstack, true) && slot.isItemValid(itemstack) && this.inventorySlots.canDragIntoSlot(slot))
|
||||
if (this.dragSplitting && slot != null && itemstack != null && itemstack.size > this.dragSplittingSlots.size() && Container.canAddItemToSlot(slot, itemstack, true) && slot.isItemValid(itemstack) && this.inventorySlots.canDragIntoSlot(slot))
|
||||
{
|
||||
this.dragSplittingSlots.add(slot);
|
||||
this.updateDragSplitting();
|
||||
|
@ -850,7 +850,7 @@ public abstract class GuiContainer extends Gui
|
|||
{
|
||||
for (Slot slot2 : this.inventorySlots.inventorySlots)
|
||||
{
|
||||
if (slot2 != null && slot2.canTakeStack(this.gm.thePlayer) && slot2.getHasStack() && slot2.inventory == slot.inventory && Container.canAddItemToSlot(slot2, this.shiftClickedSlot, true))
|
||||
if (slot2 != null && slot2.canTakeStack(this.gm.player) && slot2.getHasStack() && slot2.inventory == slot.inventory && Container.canAddItemToSlot(slot2, this.shiftClickedSlot, true))
|
||||
{
|
||||
this.handleMouseClick(slot2, slot2.slotNumber, state, 1);
|
||||
}
|
||||
|
@ -936,7 +936,7 @@ public abstract class GuiContainer extends Gui
|
|||
|
||||
this.handleMouseClick((Slot)null, -999, Container.getDragCode(2, this.dragSplittingLimit), 5);
|
||||
}
|
||||
else if (this.gm.thePlayer.inventory.getItemStack() != null)
|
||||
else if (this.gm.player.inventory.getItemStack() != null)
|
||||
{
|
||||
// if (state == this.gm.bindTertiary.getKeyCode() + 100)
|
||||
// {
|
||||
|
@ -956,7 +956,7 @@ public abstract class GuiContainer extends Gui
|
|||
}
|
||||
}
|
||||
|
||||
if (this.gm.thePlayer.inventory.getItemStack() == null)
|
||||
if (this.gm.player.inventory.getItemStack() == null)
|
||||
{
|
||||
this.lastClickTime = 0L;
|
||||
}
|
||||
|
@ -995,11 +995,11 @@ public abstract class GuiContainer extends Gui
|
|||
slotId = slotIn.slotNumber;
|
||||
}
|
||||
|
||||
this.gm.controller.windowClick(this.inventorySlots.windowId, slotId, clickedButton, clickType, this.gm.thePlayer);
|
||||
this.gm.controller.windowClick(this.inventorySlots.windowId, slotId, clickedButton, clickType, this.gm.player);
|
||||
}
|
||||
|
||||
public void dropItem() {
|
||||
if (this.gm != null && this.gm.thePlayer != null && this.theSlot != null && this.theSlot.getHasStack())
|
||||
if (this.gm != null && this.gm.player != null && this.theSlot != null && this.theSlot.getHasStack())
|
||||
{
|
||||
// if (keyCode == this.gm.bindTertiary.getKeyCode())
|
||||
// {
|
||||
|
@ -1035,7 +1035,7 @@ public abstract class GuiContainer extends Gui
|
|||
*/
|
||||
public void useHotbar(int slot)
|
||||
{
|
||||
if (!this.clickSide((this.gm.mouse_x - this.container_x) / 2, (this.gm.mouse_y - this.container_y) / 2, slot, this.gm.shift(), this.gm.ctrl()) && this.gm != null && this.gm.thePlayer != null && this.gm.thePlayer.inventory.getItemStack() == null && this.cheatStack == null && this.theSlot != null)
|
||||
if (!this.clickSide((this.gm.mouse_x - this.container_x) / 2, (this.gm.mouse_y - this.container_y) / 2, slot, this.gm.shift(), this.gm.ctrl()) && this.gm != null && this.gm.player != null && this.gm.player.inventory.getItemStack() == null && this.cheatStack == null && this.theSlot != null)
|
||||
{
|
||||
// for (int i = 0; i < 9; ++i)
|
||||
// {
|
||||
|
@ -1055,9 +1055,9 @@ public abstract class GuiContainer extends Gui
|
|||
*/
|
||||
public void onGuiClosed()
|
||||
{
|
||||
if (this.gm != null && this.gm.thePlayer != null)
|
||||
if (this.gm != null && this.gm.player != null)
|
||||
{
|
||||
this.inventorySlots.onContainerClosed(this.gm.thePlayer);
|
||||
this.inventorySlots.onContainerClosed(this.gm.player);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1076,9 +1076,9 @@ public abstract class GuiContainer extends Gui
|
|||
{
|
||||
// super.updateScreen();
|
||||
|
||||
if (this.gm != null && this.gm.thePlayer != null && (!this.gm.thePlayer.isEntityAlive() || this.gm.thePlayer.dead))
|
||||
if (this.gm != null && this.gm.player != null && (!this.gm.player.isEntityAlive() || this.gm.player.dead))
|
||||
{
|
||||
this.gm.thePlayer.closeScreen();
|
||||
this.gm.displayGuiScreen(null);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1091,13 +1091,13 @@ public abstract class GuiContainer extends Gui
|
|||
{
|
||||
if (stack != null)
|
||||
{
|
||||
if (stack.stackSize != 1 || text != null)
|
||||
if (stack.size != 1 || text != null)
|
||||
{
|
||||
String s = text == null ? ItemStack.formatAmount(stack.stackSize) : text;
|
||||
String s = text == null ? ItemStack.formatAmount(stack.size) : text;
|
||||
|
||||
if (text == null && stack.stackSize < 1)
|
||||
if (text == null && stack.size < 1)
|
||||
{
|
||||
s = TextColor.RED + ItemStack.formatAmount(stack.stackSize);
|
||||
s = TextColor.RED + ItemStack.formatAmount(stack.size);
|
||||
}
|
||||
// this.drawString(s, , );
|
||||
// Vec2i size = Drawing.txt_size(0, 0, 0, 0, 65536, 65536, s);
|
||||
|
@ -1105,7 +1105,7 @@ public abstract class GuiContainer extends Gui
|
|||
// int y = ;
|
||||
// x = x * 2 + this.container_x;
|
||||
// y = y * 2 + this.container_y;
|
||||
Drawing.drawTextRight(s, xPosition + 32, yPosition + 17, 0xffffffff);
|
||||
Drawing.drawTextRight(s, xPosition + 32, yPosition + 33 - Font.YGLYPH, 0xffffffff);
|
||||
}
|
||||
|
||||
if (stack.isItemDamaged())
|
||||
|
@ -1152,7 +1152,7 @@ public abstract class GuiContainer extends Gui
|
|||
protected void drawTab(CheatTab tab)
|
||||
{
|
||||
this.itemRender.zLevel = 100.0F;
|
||||
ItemStack itemstack = tab.getIconItemStack();
|
||||
ItemStack itemstack = tab.getIcon();
|
||||
GlState.enableDepth();
|
||||
this.itemRender.renderItemAndEffectIntoGUI(itemstack, this.xSize + 2 + 18 * tab.getHorizontal() + 1, 9 * 18 + 4 + 20 * tab.getVertical() + 1);
|
||||
this.itemRender.zLevel = 0.0F;
|
||||
|
@ -1177,13 +1177,13 @@ public abstract class GuiContainer extends Gui
|
|||
selectedTab = tab;
|
||||
this.dragSplittingSlots.clear();
|
||||
ITEM_LIST.clear();
|
||||
tab.displayAllReleventItems(ITEM_LIST);
|
||||
tab.filter(ITEM_LIST);
|
||||
|
||||
this.currentScroll = 0.0F;
|
||||
}
|
||||
|
||||
private boolean clickSide(int mouseX, int mouseY, int slot, boolean instant, boolean full) {
|
||||
if(this.gm.itemCheat && this.isPointInRegion(this.xSize + 2, 0, 18 * 12, 18 * 9, mouseX, mouseY) && this.gm.thePlayer != null && this.gm.thePlayer.inventory.getItemStack() == null && this.cheatStack == null) {
|
||||
if(this.gm.itemCheat && this.isPointInRegion(this.xSize + 2, 0, 18 * 12, 18 * 9, mouseX, mouseY) && this.gm.player != null && this.gm.player.inventory.getItemStack() == null && this.cheatStack == null) {
|
||||
int i = (ITEM_LIST.size() + 12 - 1) / 12 - 9;
|
||||
int j = (int)((double)(this.currentScroll * (float)i) + 0.5D);
|
||||
|
||||
|
@ -1198,11 +1198,11 @@ public abstract class GuiContainer extends Gui
|
|||
|
||||
if(i1 >= 0 && i1 < ITEM_LIST.size()) {
|
||||
if(slot >= 0 || instant) {
|
||||
this.gm.thePlayer.sendQueue.addToSendQueue(new CPacketCheat(ITEM_LIST.get(i1), slot, full));
|
||||
this.gm.player.client.addToSendQueue(new CPacketCheat(ITEM_LIST.get(i1), slot, full));
|
||||
}
|
||||
else {
|
||||
this.cheatStack = ITEM_LIST.get(i1).copy();
|
||||
this.cheatStack.stackSize = full ? this.cheatStack.getMaxStackSize() : 1;
|
||||
this.cheatStack.size = full ? this.cheatStack.getMaxStackSize() : 1;
|
||||
}
|
||||
return true;
|
||||
}
|
22
client/src/main/java/client/gui/container/GuiCrafting.java
Executable file
22
client/src/main/java/client/gui/container/GuiCrafting.java
Executable file
|
@ -0,0 +1,22 @@
|
|||
package client.gui.container;
|
||||
|
||||
import common.block.tech.BlockWorkbench;
|
||||
import common.inventory.ContainerWorkbench;
|
||||
import common.inventory.InventoryPlayer;
|
||||
import common.util.BlockPos;
|
||||
import common.world.World;
|
||||
|
||||
public class GuiCrafting extends GuiContainer {
|
||||
private final BlockWorkbench type;
|
||||
|
||||
public GuiCrafting(InventoryPlayer playerInv, World worldIn, BlockWorkbench type) {
|
||||
super(new ContainerWorkbench(playerInv, worldIn, BlockPos.ORIGIN, type));
|
||||
this.type = type;
|
||||
this.ySize = 112 + 18 * this.type.getSize();
|
||||
}
|
||||
|
||||
public void drawGuiContainerForegroundLayer() {
|
||||
this.drawString("Handwerk (" + this.type.getDisplay() + ")", 26, 6);
|
||||
this.drawString("Inventar", 8, this.ySize - 96 + 2);
|
||||
}
|
||||
}
|
|
@ -1,8 +1,8 @@
|
|||
package game.gui.container;
|
||||
package client.gui.container;
|
||||
|
||||
import game.inventory.ContainerDispenser;
|
||||
import game.inventory.IInventory;
|
||||
import game.inventory.InventoryPlayer;
|
||||
import common.inventory.ContainerDispenser;
|
||||
import common.inventory.IInventory;
|
||||
import common.inventory.InventoryPlayer;
|
||||
|
||||
|
||||
public class GuiDispenser extends GuiContainer
|
|
@ -1,12 +1,12 @@
|
|||
package game.gui.container;
|
||||
package client.gui.container;
|
||||
|
||||
import game.color.TextColor;
|
||||
import game.enchantment.Enchantment;
|
||||
import game.inventory.ContainerEnchantment;
|
||||
import game.inventory.InventoryPlayer;
|
||||
import game.rng.Random;
|
||||
import game.tileentity.IWorldNameable;
|
||||
import game.world.World;
|
||||
import common.color.TextColor;
|
||||
import common.enchantment.Enchantment;
|
||||
import common.inventory.ContainerEnchantment;
|
||||
import common.inventory.InventoryPlayer;
|
||||
import common.rng.Random;
|
||||
import common.util.Pair;
|
||||
import common.world.World;
|
||||
|
||||
public class GuiEnchant extends GuiContainer
|
||||
{
|
||||
|
@ -19,7 +19,7 @@ public class GuiEnchant extends GuiContainer
|
|||
private final Random nameRand = new Random();
|
||||
private final Random random = new Random();
|
||||
private final ContainerEnchantment container;
|
||||
private final IWorldNameable table;
|
||||
private final String title;
|
||||
|
||||
// public int field_147073_u;
|
||||
// public float field_147071_v;
|
||||
|
@ -30,12 +30,12 @@ public class GuiEnchant extends GuiContainer
|
|||
// public float field_147076_A;
|
||||
// ItemStack field_147077_B;
|
||||
|
||||
public GuiEnchant(InventoryPlayer inventory, World worldIn, IWorldNameable table)
|
||||
public GuiEnchant(InventoryPlayer inventory, World worldIn, String title)
|
||||
{
|
||||
super(new ContainerEnchantment(inventory, worldIn));
|
||||
this.playerInventory = inventory;
|
||||
this.container = (ContainerEnchantment)this.inventorySlots;
|
||||
this.table = table;
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -43,7 +43,7 @@ public class GuiEnchant extends GuiContainer
|
|||
*/
|
||||
public void drawGuiContainerForegroundLayer()
|
||||
{
|
||||
this.drawString(this.table.getCommandName(), 12, 5);
|
||||
this.drawString(this.title, 12, 5);
|
||||
this.drawString(this.playerInventory.getCommandName(), 8, this.ySize - 96 + 2);
|
||||
}
|
||||
|
||||
|
@ -70,7 +70,7 @@ public class GuiEnchant extends GuiContainer
|
|||
int l = mouseX - 60;
|
||||
int i1 = mouseY - (14 + 19 * k);
|
||||
|
||||
if (l >= 0 && i1 >= 0 && l < 108 && i1 < 19 && this.container.enchantItem(this.gm.thePlayer, k))
|
||||
if (l >= 0 && i1 >= 0 && l < 108 && i1 < 19 && this.container.enchantItem(this.gm.player, k))
|
||||
{
|
||||
this.gm.controller.sendEnchantPacket(this.container.windowId, k);
|
||||
}
|
||||
|
@ -89,14 +89,14 @@ public class GuiEnchant extends GuiContainer
|
|||
*/
|
||||
public void drawGuiContainerBackgroundLayer()
|
||||
{
|
||||
this.nameRand.setSeed((long)this.container.xpSeed);
|
||||
this.nameRand.setSeed((long)this.container.seed);
|
||||
|
||||
for (int l = 0; l < 3; ++l)
|
||||
{
|
||||
int i1 = 60;
|
||||
int j1 = i1 + 20;
|
||||
String s = this.getRandomName();
|
||||
int l1 = this.container.enchantLevels[l];
|
||||
int l1 = this.container.mana[l];
|
||||
|
||||
if (l1 == 0)
|
||||
{
|
||||
|
@ -107,7 +107,7 @@ public class GuiEnchant extends GuiContainer
|
|||
String s1 = "" + l1;
|
||||
int i2 = 6839882;
|
||||
|
||||
if (/* (k < l + 1 || */ this.gm.thePlayer.experienceLevel < l1) // && !this.gm.thePlayer.creative)
|
||||
if (/* (k < l + 1 || */ this.gm.player.getManaPoints() < l1) // && !this.gm.thePlayer.creative)
|
||||
{
|
||||
this.rect(i1, 14 + 19 * l, 108, 19, 0x400000);
|
||||
this.rect(i1 + 1, 15 + 19 * l, 16, 16, 0x200000);
|
||||
|
@ -150,19 +150,16 @@ public class GuiEnchant extends GuiContainer
|
|||
|
||||
for (int j = 0; j < 3; ++j)
|
||||
{
|
||||
int k = this.container.enchantLevels[j];
|
||||
int l = this.container.enchantmentIds[j];
|
||||
int k = this.container.mana[j];
|
||||
Pair<Enchantment, Integer> l = this.container.ench[j];
|
||||
int i1 = j + 1;
|
||||
|
||||
if (this.isPointInRegion(60, 14 + 19 * j, 108, 17, mouseX, mouseY) && k > 0 && l >= 0)
|
||||
if (this.isPointInRegion(60, 14 + 19 * j, 108, 17, mouseX, mouseY) && k > 0 && l != null)
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
if (l >= 0 && Enchantment.getEnchantmentById(l & 255) != null)
|
||||
{
|
||||
String s = Enchantment.getEnchantmentById(l & 255).getFormattedName((l & 65280) >> 8);
|
||||
sb.append(TextColor.WHITE + s + " . . . ?");
|
||||
}
|
||||
String s = l.first().getFormattedName(l.second());
|
||||
sb.append(TextColor.WHITE + s + " . . . ?");
|
||||
|
||||
// if (!flag)
|
||||
// {
|
||||
|
@ -171,9 +168,9 @@ public class GuiEnchant extends GuiContainer
|
|||
// sb.append("\n");
|
||||
// }
|
||||
|
||||
if (this.gm.thePlayer.experienceLevel < k)
|
||||
if (this.gm.player.getManaPoints() < k)
|
||||
{
|
||||
sb.append((sb.length() != 0 ? "\n" : "") + TextColor.RED + String.format("Erfahrungsstufe %d erforderlich", this.container.enchantLevels[j]));
|
||||
sb.append((sb.length() != 0 ? "\n" : "") + TextColor.RED + String.format("%d Mana erforderlich", this.container.mana[j]));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -199,11 +196,11 @@ public class GuiEnchant extends GuiContainer
|
|||
|
||||
if (i1 == 1)
|
||||
{
|
||||
s1 = "1 Erfahrungsstufe";
|
||||
s1 = "1 Manapunkt";
|
||||
}
|
||||
else
|
||||
{
|
||||
s1 = String.format("%d Erfahrungsstufen", i1);
|
||||
s1 = String.format("%d Manapunkte", i1);
|
||||
}
|
||||
|
||||
sb.append((sb.length() != 0 ? "\n" : "") + TextColor.LGRAY.toString() + "" + s1);
|
|
@ -1,45 +1,26 @@
|
|||
package game.gui.container;
|
||||
package client.gui.container;
|
||||
|
||||
import game.Game;
|
||||
import game.entity.animal.EntityHorse;
|
||||
import game.inventory.ContainerHorseInventory;
|
||||
import game.inventory.IInventory;
|
||||
import client.Client;
|
||||
import common.entity.Entity;
|
||||
import common.inventory.ContainerEntityInventory;
|
||||
import common.inventory.IInventory;
|
||||
|
||||
|
||||
public class GuiHorse extends GuiContainer
|
||||
public class GuiEntity extends GuiContainer
|
||||
{
|
||||
// private static final String horseGuiTextures = "textures/gui/horse.png";
|
||||
|
||||
/** The player inventory bound to this GUI. */
|
||||
private IInventory playerInventory;
|
||||
private IInventory entityInventory;
|
||||
|
||||
/** The horse inventory bound to this GUI. */
|
||||
private IInventory horseInventory;
|
||||
|
||||
// /** The EntityHorse whose inventory is currently being accessed. */
|
||||
// private EntityHorse horseEntity;
|
||||
|
||||
// /** The mouse x-position recorded during the last rendered frame. */
|
||||
// private float mousePosx;
|
||||
//
|
||||
// /** The mouse y-position recorded during the last renderered frame. */
|
||||
// private float mousePosY;
|
||||
|
||||
public GuiHorse(IInventory playerInv, IInventory horseInv, EntityHorse horse)
|
||||
public GuiEntity(IInventory playerInv, IInventory entityInv, Entity entity)
|
||||
{
|
||||
super(new ContainerHorseInventory(playerInv, horseInv, horse, Game.getGame().thePlayer));
|
||||
super(new ContainerEntityInventory(playerInv, entityInv, entity, Client.CLIENT.player));
|
||||
this.playerInventory = playerInv;
|
||||
this.horseInventory = horseInv;
|
||||
// this.horseEntity = horse;
|
||||
// this.allowUserInput = false;
|
||||
this.entityInventory = entityInv;
|
||||
}
|
||||
|
||||
/**
|
||||
* Draw the foreground layer for the GuiContainer (everything in front of the items). Args : mouseX, mouseY
|
||||
*/
|
||||
public void drawGuiContainerForegroundLayer()
|
||||
{
|
||||
this.drawString(this.horseInventory.getCommandName(), 8, 6);
|
||||
this.drawString(this.entityInventory.getCommandName(), 8, 6);
|
||||
this.drawString(this.playerInventory.getCommandName(), 8, this.ySize - 96 + 2);
|
||||
}
|
||||
|
|
@ -1,9 +1,9 @@
|
|||
package game.gui.container;
|
||||
package client.gui.container;
|
||||
|
||||
import game.inventory.ContainerFurnace;
|
||||
import game.inventory.IInventory;
|
||||
import game.inventory.InventoryPlayer;
|
||||
import game.tileentity.TileEntityFurnace;
|
||||
import common.inventory.ContainerFurnace;
|
||||
import common.inventory.IInventory;
|
||||
import common.inventory.InventoryPlayer;
|
||||
import common.tileentity.TileEntityFurnace;
|
||||
|
||||
|
||||
public class GuiFurnace extends GuiContainer
|
|
@ -1,9 +1,9 @@
|
|||
package game.gui.container;
|
||||
package client.gui.container;
|
||||
|
||||
import game.Game;
|
||||
import game.inventory.ContainerHopper;
|
||||
import game.inventory.IInventory;
|
||||
import game.inventory.InventoryPlayer;
|
||||
import client.Client;
|
||||
import common.inventory.ContainerHopper;
|
||||
import common.inventory.IInventory;
|
||||
import common.inventory.InventoryPlayer;
|
||||
|
||||
|
||||
public class GuiHopper extends GuiContainer
|
||||
|
@ -19,7 +19,7 @@ public class GuiHopper extends GuiContainer
|
|||
|
||||
public GuiHopper(InventoryPlayer playerInv, IInventory hopperInv)
|
||||
{
|
||||
super(new ContainerHopper(playerInv, hopperInv, Game.getGame().thePlayer));
|
||||
super(new ContainerHopper(playerInv, hopperInv, Client.CLIENT.player));
|
||||
this.playerInventory = playerInv;
|
||||
this.hopperInventory = hopperInv;
|
||||
// this.allowUserInput = false;
|
|
@ -1,6 +1,6 @@
|
|||
package game.gui.container;
|
||||
package client.gui.container;
|
||||
|
||||
import game.entity.npc.EntityNPC;
|
||||
import common.entity.npc.EntityNPC;
|
||||
|
||||
public class GuiInventory extends GuiContainer
|
||||
{
|
|
@ -1,16 +1,16 @@
|
|||
package game.gui.container;
|
||||
package client.gui.container;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import game.inventory.ContainerMerchant;
|
||||
import game.inventory.InventoryPlayer;
|
||||
import game.item.ItemStack;
|
||||
import game.packet.CPacketAction;
|
||||
import game.renderer.GlState;
|
||||
import game.renderer.ItemRenderer;
|
||||
import game.village.MerchantRecipe;
|
||||
import game.village.MerchantRecipeList;
|
||||
import game.world.World;
|
||||
import client.renderer.GlState;
|
||||
import client.renderer.ItemRenderer;
|
||||
import common.inventory.ContainerMerchant;
|
||||
import common.inventory.InventoryPlayer;
|
||||
import common.item.ItemStack;
|
||||
import common.packet.CPacketAction;
|
||||
import common.village.MerchantRecipe;
|
||||
import common.village.MerchantRecipeList;
|
||||
import common.world.World;
|
||||
|
||||
public class GuiMerchant extends GuiContainer
|
||||
{
|
||||
|
@ -81,9 +81,9 @@ public class GuiMerchant extends GuiContainer
|
|||
if (merchantrecipelist != null && !merchantrecipelist.isEmpty()) {
|
||||
int k = this.selectedMerchantRecipe;
|
||||
MerchantRecipe merchantrecipe = (MerchantRecipe)merchantrecipelist.get(k);
|
||||
ItemStack itemstack = merchantrecipe.getItemToBuy();
|
||||
ItemStack itemstack1 = merchantrecipe.getSecondItemToBuy();
|
||||
ItemStack itemstack2 = merchantrecipe.getItemToSell();
|
||||
ItemStack itemstack = merchantrecipe.first();
|
||||
ItemStack itemstack1 = merchantrecipe.second();
|
||||
ItemStack itemstack2 = merchantrecipe.result();
|
||||
this.renderItemOverlayIntoGUI(itemstack, 36, 24, null);
|
||||
if(itemstack1 != null)
|
||||
this.renderItemOverlayIntoGUI(itemstack1, 62, 24, null);
|
||||
|
@ -180,9 +180,9 @@ public class GuiMerchant extends GuiContainer
|
|||
// int j = (this.height - this.ySize) / 2;
|
||||
int k = this.selectedMerchantRecipe;
|
||||
MerchantRecipe merchantrecipe = (MerchantRecipe)merchantrecipelist.get(k);
|
||||
ItemStack itemstack = merchantrecipe.getItemToBuy();
|
||||
ItemStack itemstack1 = merchantrecipe.getSecondItemToBuy();
|
||||
ItemStack itemstack2 = merchantrecipe.getItemToSell();
|
||||
ItemStack itemstack = merchantrecipe.first();
|
||||
ItemStack itemstack1 = merchantrecipe.second();
|
||||
ItemStack itemstack2 = merchantrecipe.result();
|
||||
GL11.glPushMatrix();
|
||||
ItemRenderer.enableGUIStandardItemLighting();
|
||||
GlState.disableLighting();
|
|
@ -1,15 +1,15 @@
|
|||
package game.gui.container;
|
||||
package client.gui.container;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import game.Game;
|
||||
import game.inventory.Container;
|
||||
import game.inventory.ContainerRepair;
|
||||
import game.inventory.ICrafting;
|
||||
import game.inventory.IInventory;
|
||||
import game.inventory.InventoryPlayer;
|
||||
import game.item.ItemStack;
|
||||
import game.world.World;
|
||||
import client.Client;
|
||||
import common.inventory.Container;
|
||||
import common.inventory.ContainerRepair;
|
||||
import common.inventory.ICrafting;
|
||||
import common.inventory.IInventory;
|
||||
import common.inventory.InventoryPlayer;
|
||||
import common.item.ItemStack;
|
||||
import common.world.World;
|
||||
|
||||
public class GuiRepair extends GuiContainer implements ICrafting
|
||||
{
|
||||
|
@ -21,7 +21,7 @@ public class GuiRepair extends GuiContainer implements ICrafting
|
|||
|
||||
public GuiRepair(InventoryPlayer inventoryIn, World worldIn)
|
||||
{
|
||||
super(new ContainerRepair(inventoryIn, worldIn, Game.getGame().thePlayer));
|
||||
super(new ContainerRepair(inventoryIn, worldIn, Client.CLIENT.player));
|
||||
this.playerInventory = inventoryIn;
|
||||
this.anvil = (ContainerRepair)this.inventorySlots;
|
||||
}
|
||||
|
@ -68,7 +68,7 @@ public class GuiRepair extends GuiContainer implements ICrafting
|
|||
{
|
||||
int i = 8453920;
|
||||
boolean flag = true;
|
||||
String s = String.format("Erfahrungskosten: %d", this.anvil.maximumCost);
|
||||
String s = String.format("Manakosten: %d", this.anvil.maximumCost);
|
||||
|
||||
if (this.anvil.maximumCost >= 40) // && !this.gm.thePlayer.creative)
|
||||
{
|
32
client/src/main/java/client/gui/container/GuiTile.java
Executable file
32
client/src/main/java/client/gui/container/GuiTile.java
Executable file
|
@ -0,0 +1,32 @@
|
|||
package client.gui.container;
|
||||
|
||||
import client.Client;
|
||||
import common.inventory.ContainerTile;
|
||||
import common.inventory.IInventory;
|
||||
import common.inventory.InventoryPlayer;
|
||||
import common.tileentity.TileEntityDevice;
|
||||
|
||||
|
||||
public class GuiTile extends GuiContainer
|
||||
{
|
||||
private final IInventory playerInv;
|
||||
private final IInventory tileInv;
|
||||
private final TileEntityDevice tile;
|
||||
|
||||
public GuiTile(InventoryPlayer player, IInventory inv, TileEntityDevice tile)
|
||||
{
|
||||
super(new ContainerTile(player, tile, inv, Client.CLIENT.player));
|
||||
this.playerInv = player;
|
||||
this.tileInv = tile;
|
||||
this.ySize = 153;
|
||||
this.tile = tile;
|
||||
}
|
||||
|
||||
public void drawGuiContainerForegroundLayer()
|
||||
{
|
||||
this.drawString(this.tile.getStatus().color + this.tileInv.getCommandName() + " - " + this.tile.getStatus().name, 8, 6);
|
||||
this.drawString(this.playerInv.getCommandName(), 8, this.ySize - 96 + 2);
|
||||
this.drawString(String.format("Temperatur: %d °", this.tile.getTemperature()), 8, 18);
|
||||
this.drawString(this.tile.formatDisplay((ContainerTile)this.inventorySlots), 8, 28);
|
||||
}
|
||||
}
|
26
client/src/main/java/client/gui/element/ActButton.java
Normal file
26
client/src/main/java/client/gui/element/ActButton.java
Normal file
|
@ -0,0 +1,26 @@
|
|||
package client.gui.element;
|
||||
|
||||
import client.gui.Formatter;
|
||||
import client.window.Button;
|
||||
|
||||
public class ActButton extends Element {
|
||||
private final ButtonCallback func;
|
||||
|
||||
public ActButton(int x, int y, int w, int h, ButtonCallback callback, Formatter<ActButton> formatter) {
|
||||
super(x, y, w, h, formatter);
|
||||
this.func = callback;
|
||||
this.formatText();
|
||||
}
|
||||
|
||||
public ActButton(int x, int y, int w, int h, ButtonCallback callback, String text) {
|
||||
super(x, y, w, h, null);
|
||||
this.func = callback;
|
||||
this.setText(text);
|
||||
}
|
||||
|
||||
public void mouse(Button btn, int x, int y, boolean ctrl, boolean shift) {
|
||||
this.func.use(this, (ctrl || (btn == Button.MOUSE_MIDDLE)) ? PressType.TERTIARY : ((shift || (btn == Button.MOUSE_RIGHT)) ? PressType.SECONDARY : PressType.PRIMARY));
|
||||
this.formatText();
|
||||
this.playSound();
|
||||
}
|
||||
}
|
159
client/src/main/java/client/gui/element/Area.java
Normal file
159
client/src/main/java/client/gui/element/Area.java
Normal file
|
@ -0,0 +1,159 @@
|
|||
package client.gui.element;
|
||||
|
||||
import client.gui.Font;
|
||||
import client.renderer.Drawing;
|
||||
import client.renderer.Drawing.Offset;
|
||||
import client.renderer.Drawing.Vec2i;
|
||||
import common.util.CharValidator;
|
||||
import common.util.ExtMath;
|
||||
import common.util.Util;
|
||||
|
||||
public class Area extends Textbox {
|
||||
private int textHeight;
|
||||
private int scrollPos;
|
||||
private int cursorX;
|
||||
private int cursorY;
|
||||
|
||||
private Area(int x, int y, int w, int h, int cap, boolean editable, CharValidator validator, String text) {
|
||||
super(x, y, w, h, cap, editable, null, validator);
|
||||
this.setText(text);
|
||||
}
|
||||
|
||||
public Area(int x, int y, int w, int h, int cap, CharValidator validator, String text) {
|
||||
this(x, y, w, h, cap, true, validator, text);
|
||||
}
|
||||
|
||||
public Area(int x, int y, int w, int h, int cap, String text) {
|
||||
this(x, y, w, h, cap, true, null, text);
|
||||
}
|
||||
|
||||
public Area(int x, int y, int w, int h, String text) {
|
||||
this(x, y, w, h, Integer.MAX_VALUE, false, null, text);
|
||||
}
|
||||
|
||||
public void updateText() {
|
||||
this.textHeight = Drawing.txt_size(this.pos_x + this.margin_x1, this.pos_y + this.margin_y1,
|
||||
this.pos_x + this.margin_x1, this.pos_y + this.margin_y1,
|
||||
this.pos_x + (this.size_x - (this.margin_x1 + this.margin_x2)), Integer.MAX_VALUE, this.text).ypos;
|
||||
}
|
||||
|
||||
public void scroll(int scr_x, int scr_y, int x, int y, boolean ctrl, boolean shift) {
|
||||
if(scr_y != 0) {
|
||||
int limit = Font.YGLYPH + this.textHeight - (this.size_y - (this.margin_y1 + this.margin_y2));
|
||||
limit = ExtMath.clampi(limit, 0, 0x7fffffff);
|
||||
int prev = this.text_y;
|
||||
this.text_y += (scr_y < 0 ? -1 : 1) * (ctrl ? 1 : Font.YGLYPH) * this.gm.scrollLines * (shift ? 10 : 1);
|
||||
this.text_y = ExtMath.clampi(this.text_y, -limit, 0);
|
||||
if(this.sel_start >= 0)
|
||||
this.cursorY += (this.text_y - prev);
|
||||
}
|
||||
}
|
||||
|
||||
public void mouserel() {
|
||||
this.scrollPos = 0;
|
||||
}
|
||||
|
||||
public void onReturn(boolean shift) {
|
||||
insertText("\n");
|
||||
}
|
||||
|
||||
public void onSelection(boolean up) {
|
||||
if(!up && this.sel_start != this.sel_end) {
|
||||
this.sel_start = this.sel_drag = this.sel_end;
|
||||
}
|
||||
else if(up && this.sel_start != this.sel_end) {
|
||||
this.sel_end = this.sel_drag = this.sel_start;
|
||||
}
|
||||
if(!up && this.sel_start >= 0) {
|
||||
if(this.sel_end < this.text.length()) {
|
||||
int nl = this.text.indexOf('\n', this.sel_end);
|
||||
this.sel_end = nl >= 0 ? nl + 1 : this.text.length();
|
||||
this.sel_start = this.sel_drag = this.sel_end;
|
||||
}
|
||||
else {
|
||||
this.sel_end = this.sel_drag = this.sel_start;
|
||||
}
|
||||
gui_text_update_cur(this.sel_end, true);
|
||||
}
|
||||
else if(up && this.sel_start >= 0) {
|
||||
if(this.sel_start > 0) {
|
||||
int nl = this.text.lastIndexOf('\n', this.sel_start);
|
||||
this.sel_start = nl >= 0 ? nl : 0;
|
||||
}
|
||||
this.sel_end = this.sel_drag = this.sel_start;
|
||||
gui_text_update_cur(this.sel_end, true);
|
||||
}
|
||||
}
|
||||
|
||||
public void update() {
|
||||
if(this.scrollPos != 0) {
|
||||
int n = this.updateScroll(this.scrollPos);
|
||||
this.text_y += n;
|
||||
if(n != 0)
|
||||
gui_text_clamp_scroll();
|
||||
}
|
||||
}
|
||||
|
||||
public void shift(int shift_x, int shift_y) {
|
||||
super.shift(shift_x, shift_y);
|
||||
this.cursorX += shift_x;
|
||||
this.cursorY += shift_y;
|
||||
}
|
||||
|
||||
protected void gui_text_clamp_scroll() {
|
||||
int limit = Font.YGLYPH + this.textHeight - (this.size_y - (this.margin_y1 + this.margin_y2));
|
||||
limit = ExtMath.clampi(limit, 0, 0x7fffffff);
|
||||
this.text_y = ExtMath.clampi(this.text_y, -limit, 0);
|
||||
}
|
||||
|
||||
protected void updateCursor(int offset, boolean shift, int x1, int y1, int x2, int y2) {
|
||||
Vec2i coord = Drawing.txt_coord(offset, x1, y1 + this.text_y,
|
||||
x1 + this.text_x, y1 + this.text_y, this.pos_x + x2, 0x7fffffff, this.text);
|
||||
this.cursorX = coord.xpos;
|
||||
this.cursorY = coord.ypos;
|
||||
if(shift) {
|
||||
if(this.cursorY < y1)
|
||||
this.text_y += y1 - this.cursorY;
|
||||
else if((this.cursorY + Font.YGLYPH) >= (y1 + y2))
|
||||
this.text_y -= (this.cursorY + Font.YGLYPH) - (y1 + y2);
|
||||
gui_text_update_cur(offset, false);
|
||||
}
|
||||
}
|
||||
|
||||
protected int onCursorOffset(int x, int y, int x1, int y1, int x2, int y2) {
|
||||
Offset off = Drawing.txt_offset(x, y, x1, y1 + this.text_y,
|
||||
x1 + this.text_x, y1 + this.text_y, this.pos_x + x2, 0x7fffffff, this.text);
|
||||
if(off != null) {
|
||||
this.cursorX = off.xpos;
|
||||
this.cursorY = off.ypos;
|
||||
}
|
||||
int offset = off == null ? 0 : off.offset;
|
||||
if(y < y1)
|
||||
this.scrollPos = y1 - y;
|
||||
else if(y >= (y1 + y2))
|
||||
this.scrollPos = -(y - (y1 + y2));
|
||||
return offset;
|
||||
}
|
||||
|
||||
protected void drawForeground(int x1, int y1, int x2, int y2) {
|
||||
Drawing.txt_draw(x1, y1 + this.text_y,
|
||||
x1 + this.text_x, y1 + this.text_y,
|
||||
this.pos_x + x2, Integer.MAX_VALUE, this.enabled ? this.gm.style.text_field : Util.mulColor(this.gm.style.text_field, 0.5f), this.text);
|
||||
if(this.sel_start >= 0 && this.sel_end != this.sel_start)
|
||||
Drawing.txt_overlay(this.sel_start, this.sel_end, x1, y1 + this.text_y,
|
||||
x1 + this.text_x, y1 + this.text_y,
|
||||
this.pos_x + x2, Integer.MAX_VALUE, this.enabled ? 0x808080ff : 0x80404040, this.text);
|
||||
}
|
||||
|
||||
protected char getNewline() {
|
||||
return '\n';
|
||||
}
|
||||
|
||||
protected int getCursorX(int x1, int x2) {
|
||||
return this.cursorX;
|
||||
}
|
||||
|
||||
protected int getCursorY(int y1, int y2) {
|
||||
return this.cursorY;
|
||||
}
|
||||
}
|
|
@ -1,8 +1,8 @@
|
|||
package game.gui.element;
|
||||
package client.gui.element;
|
||||
|
||||
import game.renderer.Drawing;
|
||||
import game.util.ExtMath;
|
||||
import game.util.Util;
|
||||
import client.renderer.Drawing;
|
||||
import common.util.ExtMath;
|
||||
import common.util.Util;
|
||||
|
||||
public class Bar extends Fill {
|
||||
private int color = 0x00ff00;
|
|
@ -0,0 +1,5 @@
|
|||
package client.gui.element;
|
||||
|
||||
public interface ButtonCallback {
|
||||
void use(ActButton elem, PressType action);
|
||||
}
|
|
@ -1,13 +1,13 @@
|
|||
package game.gui.element;
|
||||
package client.gui.element;
|
||||
|
||||
import game.gui.Font;
|
||||
import game.gui.Gui;
|
||||
import game.renderer.Drawing;
|
||||
import game.util.Displayable;
|
||||
import game.util.ExtMath;
|
||||
import game.util.Formatter;
|
||||
import game.util.Util;
|
||||
import game.window.Button;
|
||||
import client.gui.Font;
|
||||
import client.gui.Formatter;
|
||||
import client.gui.Gui;
|
||||
import client.renderer.Drawing;
|
||||
import client.window.Button;
|
||||
import common.util.Displayable;
|
||||
import common.util.ExtMath;
|
||||
import common.util.Util;
|
||||
|
||||
public class Dropdown<T> extends Element {
|
||||
public class Handle extends Element {
|
||||
|
@ -17,7 +17,7 @@ public class Dropdown<T> extends Element {
|
|||
for(T value : Dropdown.this.values) {
|
||||
if(sb.length() > 0)
|
||||
sb.append('\n');
|
||||
sb.append(value instanceof Displayable ? ((Displayable)value).getDisplay() : value.toString());
|
||||
sb.append(value instanceof Displayable disp ? disp.getDisplay() : value.toString());
|
||||
}
|
||||
this.setText(sb.toString());
|
||||
this.visible = /* this.r_dirty = */ false;
|
||||
|
@ -64,18 +64,14 @@ public class Dropdown<T> extends Element {
|
|||
}
|
||||
}
|
||||
|
||||
public static interface Callback<T> {
|
||||
void use(Dropdown<T> elem, T value);
|
||||
}
|
||||
|
||||
private final Callback<T> func;
|
||||
private final DropdownCallback<T> func;
|
||||
private final T[] values;
|
||||
private final Handle handle;
|
||||
private final int def;
|
||||
|
||||
private int value;
|
||||
|
||||
public Dropdown(int x, int y, int w, int h, boolean up, T[] values, T def, T init, Callback<T> callback, Formatter<Dropdown<T>> formatter) {
|
||||
public Dropdown(int x, int y, int w, int h, boolean up, T[] values, T def, T init, DropdownCallback<T> callback, Formatter<Dropdown<T>> formatter) {
|
||||
super(x, y, w, h, formatter);
|
||||
this.func = callback;
|
||||
this.values = values;
|
||||
|
@ -85,11 +81,16 @@ public class Dropdown<T> extends Element {
|
|||
this.formatText();
|
||||
}
|
||||
|
||||
public Dropdown(int x, int y, int w, int h, boolean up, T[] values, T def, T init, Callback<T> callback, final String text) {
|
||||
this(x, y, w, h, up, values, def, init, callback, new Formatter<Dropdown<T>>() {
|
||||
public Dropdown(int x, int y, int w, int h, boolean up, T[] values, T def, T init, DropdownCallback<T> callback, final String text) {
|
||||
this(x, y, w, h, up, values, def, init, callback, text == null ? new Formatter<Dropdown<T>>() {
|
||||
public String use(Dropdown<T> elem) {
|
||||
T value = elem.getValue();
|
||||
return String.format("%s: %s", text, value instanceof Displayable ? ((Displayable)value).getDisplay() : value.toString());
|
||||
return value instanceof Displayable disp ? disp.getDisplay() : value.toString();
|
||||
}
|
||||
} : new Formatter<Dropdown<T>>() {
|
||||
public String use(Dropdown<T> elem) {
|
||||
T value = elem.getValue();
|
||||
return String.format("%s: %s", text, value instanceof Displayable disp ? disp.getDisplay() : value.toString());
|
||||
}
|
||||
});
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
package client.gui.element;
|
||||
|
||||
public interface DropdownCallback<T> {
|
||||
void use(Dropdown<T> elem, T value);
|
||||
}
|
|
@ -1,21 +1,23 @@
|
|||
package game.gui.element;
|
||||
package client.gui.element;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import game.Game;
|
||||
import game.audio.PositionedSound;
|
||||
import game.audio.Volume;
|
||||
import game.gui.Gui;
|
||||
import game.init.SoundEvent;
|
||||
import game.renderer.Drawing;
|
||||
import game.renderer.Drawing.Vec2i;
|
||||
import game.util.Formatter;
|
||||
import game.util.Util;
|
||||
import game.window.Button;
|
||||
import game.window.Keysym;
|
||||
import client.Client;
|
||||
import client.gui.Formatter;
|
||||
import client.gui.Gui;
|
||||
import client.renderer.Drawing;
|
||||
import client.renderer.Drawing.Vec2i;
|
||||
import client.window.Button;
|
||||
import client.window.Keysym;
|
||||
import common.init.SoundEvent;
|
||||
import common.sound.EventType;
|
||||
import common.sound.PositionedSound;
|
||||
import common.util.Util;
|
||||
|
||||
public abstract class Element {
|
||||
protected final Game gm = Game.getGame();
|
||||
public static final int BASE_HEIGHT = 18;
|
||||
|
||||
protected final Client gm = Client.CLIENT;
|
||||
|
||||
protected Gui gui;
|
||||
protected Formatter format;
|
||||
|
@ -36,12 +38,11 @@ public abstract class Element {
|
|||
public boolean visible = true;
|
||||
public boolean enabled = true;
|
||||
|
||||
|
||||
public Element(int x, int y, int w, int h, Formatter formatter) {
|
||||
this.pos_x = x;
|
||||
this.pos_y = y;
|
||||
this.size_x = w;
|
||||
this.size_y = h;
|
||||
this.size_y = h <= 0 ? BASE_HEIGHT : h;
|
||||
this.format = formatter;
|
||||
// gui_update_style(this, 1);
|
||||
// if(type != ElemType.SLIDER) {
|
||||
|
@ -112,8 +113,8 @@ public abstract class Element {
|
|||
|
||||
public void updateText() {
|
||||
Vec2i size = Drawing.getSize(this.text);
|
||||
this.text_x = (this.size_x - size.xpos) / 2;
|
||||
this.text_y = (this.size_y - size.ypos) / 2;
|
||||
this.text_x = ((this.size_x - (this.margin_x1 + this.margin_x2)) - size.xpos) / 2;
|
||||
this.text_y = ((this.size_y - (this.margin_y1 + this.margin_y2)) - size.ypos + 1) / 2;
|
||||
}
|
||||
|
||||
public void setText(String str) {
|
||||
|
@ -220,7 +221,7 @@ public abstract class Element {
|
|||
int x2 = this.size_x - (this.margin_x1 + this.margin_x2);
|
||||
int y2 = this.size_y - (this.margin_y1 + this.margin_y2);
|
||||
// if(elem.type == ElemType.FIELD) {
|
||||
GL11.glScissor(x1 < 0 ? 0 : x1, (this.gm.fb_y - (y1 + y2)) < 0 ? 0 : (this.gm.fb_y - (y1 + y2)), x2 < 0 ? 0 : x2, y2 < 0 ? 0 : y2);
|
||||
this.gm.scissor(x1 < 0 ? 0 : x1, (this.gm.fb_y - (y1 + y2)) < 0 ? 0 : (this.gm.fb_y - (y1 + y2)), x2 < 0 ? 0 : x2, y2 < 0 ? 0 : y2);
|
||||
GL11.glEnable(GL11.GL_SCISSOR_TEST);
|
||||
// }
|
||||
// if(this.type == ElemType.CUSTOM)
|
||||
|
@ -266,6 +267,6 @@ public abstract class Element {
|
|||
}
|
||||
|
||||
public void playSound() {
|
||||
this.gm.getSoundManager().playSound(new PositionedSound(SoundEvent.CLICK, Volume.GUI));
|
||||
this.gm.getSoundManager().playSound(new PositionedSound(SoundEvent.CLICK, EventType.UI_INTERFACE));
|
||||
}
|
||||
}
|
198
client/src/main/java/client/gui/element/Field.java
Normal file
198
client/src/main/java/client/gui/element/Field.java
Normal file
|
@ -0,0 +1,198 @@
|
|||
package client.gui.element;
|
||||
|
||||
import client.gui.Font;
|
||||
import client.renderer.Drawing;
|
||||
import client.renderer.Drawing.Offset;
|
||||
import client.renderer.Drawing.Vec2i;
|
||||
import common.util.CharValidator;
|
||||
import common.util.ExtMath;
|
||||
import common.util.Util;
|
||||
|
||||
public class Field extends Textbox {
|
||||
private int textWidth;
|
||||
private int scrollPos;
|
||||
private int cursorPos;
|
||||
|
||||
private Field(int x, int y, int w, int h, int cap, boolean editable, FieldCallback callback, CharValidator validator, String text) {
|
||||
super(x, y, w, h, cap, editable, callback, validator);
|
||||
this.text_y = (this.size_y - (this.margin_y1 + this.margin_y2 + Font.YGLYPH)) / 2;
|
||||
this.setText(text);
|
||||
}
|
||||
|
||||
public Field(int x, int y, int w, int h, int cap, FieldCallback callback, CharValidator validator, String text) {
|
||||
this(x, y, w, h, cap, true, callback, validator, text);
|
||||
}
|
||||
|
||||
public Field(int x, int y, int w, int h, int cap, FieldCallback callback, String text) {
|
||||
this(x, y, w, h, cap, true, callback, null, text);
|
||||
}
|
||||
|
||||
public Field(int x, int y, int w, int h, String text) {
|
||||
this(x, y, w, h, Integer.MAX_VALUE, false, null, null, text);
|
||||
}
|
||||
|
||||
public void updateText() {
|
||||
this.textWidth = Drawing.txt_size(this.pos_x + this.margin_x1, this.pos_y + this.margin_y1,
|
||||
this.pos_x + this.margin_x1, this.pos_y + this.margin_y1,
|
||||
Integer.MAX_VALUE, Integer.MAX_VALUE, this.getDrawnText()).xpos;
|
||||
}
|
||||
|
||||
public void mouserel() {
|
||||
this.scrollPos = 0;
|
||||
}
|
||||
|
||||
public void onReturn(boolean shift) {
|
||||
if(this.func != null) {
|
||||
this.func.use(this, shift ? FieldAction.LINE : FieldAction.SEND);
|
||||
}
|
||||
}
|
||||
|
||||
public void onSelection(boolean up) {
|
||||
if(this.func != null) {
|
||||
this.func.use(this, up ? FieldAction.PREVIOUS : FieldAction.NEXT);
|
||||
}
|
||||
}
|
||||
|
||||
public void update() {
|
||||
if(this.scrollPos != 0) {
|
||||
int n = this.updateScroll(this.scrollPos);
|
||||
this.text_x += n;
|
||||
if(n != 0)
|
||||
gui_text_clamp_scroll();
|
||||
}
|
||||
}
|
||||
|
||||
public void shift(int shift_x, int shift_y) {
|
||||
super.shift(shift_x, shift_y);
|
||||
this.cursorPos += shift_x;
|
||||
}
|
||||
|
||||
public void scroll(int scr_x, int scr_y, int x, int y, boolean ctrl, boolean shift) {
|
||||
if(scr_y != 0 || scr_x != 0) {
|
||||
int limit = Font.XGLYPH + this.textWidth - (this.size_x - (this.margin_x1 + this.margin_x2));
|
||||
limit = ExtMath.clampi(limit, 0, 0x7fffffff);
|
||||
int prev = this.text_x;
|
||||
this.text_x += ((scr_y != 0 ? scr_y : (-scr_x)) < 0 ? -1 : 1) * (ctrl ? 1 : Font.XGLYPH) * this.gm.scrollLines * (shift ? 10 : 1);
|
||||
this.text_x = ExtMath.clampi(this.text_x, -limit, 0);
|
||||
if(this.sel_start >= 0)
|
||||
this.cursorPos += (this.text_x - prev);
|
||||
}
|
||||
}
|
||||
|
||||
protected int getCursorX(int x1, int x2) {
|
||||
return this.cursorPos;
|
||||
}
|
||||
|
||||
protected int getCursorY(int y1, int y2) {
|
||||
return y1 + (y2 - Font.YGLYPH) / 2;
|
||||
}
|
||||
|
||||
protected void gui_text_clamp_scroll() {
|
||||
int limit = Font.XGLYPH + this.textWidth - (this.size_x - (this.margin_x1 + this.margin_x2));
|
||||
limit = ExtMath.clampi(limit, 0, 0x7fffffff);
|
||||
this.text_x = ExtMath.clampi(this.text_x, -limit, 0);
|
||||
}
|
||||
|
||||
protected void updateCursor(int offset, boolean shift, int x1, int y1, int x2, int y2) {
|
||||
Vec2i coord = Drawing.txt_coord(offset, x1 + this.text_x, y1 + this.text_y,
|
||||
x1 + this.text_x, y1 + this.text_y, 0x7fffffff, 0x7fffffff, this.getDrawnText());
|
||||
this.cursorPos = coord.xpos;
|
||||
if(shift) {
|
||||
if(this.cursorPos < x1)
|
||||
this.text_x += x1 - this.cursorPos;
|
||||
else if((this.cursorPos + Font.XGLYPH) >= (x1 + x2))
|
||||
this.text_x -= (this.cursorPos + Font.XGLYPH) - (x1 + x2);
|
||||
gui_text_update_cur(offset, false);
|
||||
}
|
||||
}
|
||||
|
||||
protected int onCursorOffset(int x, int y, int x1, int y1, int x2, int y2) {
|
||||
Offset off = Drawing.txt_offset(x, y, x1 + this.text_x, y1 + this.text_y,
|
||||
x1 + this.text_x, y1 + this.text_y, 0x7fffffff, 0x7fffffff, this.getDrawnText());
|
||||
if(off != null) {
|
||||
this.cursorPos = off.xpos;
|
||||
}
|
||||
int offset = off == null ? 0 : off.offset;
|
||||
if(x < x1)
|
||||
this.scrollPos = x1 - x;
|
||||
else if(x >= (x1 + x2))
|
||||
this.scrollPos = -(x - (x1 + x2));
|
||||
return offset;
|
||||
}
|
||||
|
||||
protected void drawBackground() {
|
||||
if(this.enabled)
|
||||
Drawing.drawGradientBorder(this.pos_x, this.pos_y, this.size_x, this.size_y, this.gm.style.field_top, this.gm.style.field_btm, 0xff000000, this.gm.style.brdr_top, this.gm.style.brdr_btm);
|
||||
else
|
||||
Drawing.drawGradientBorder(this.pos_x, this.pos_y, this.size_x, this.size_y, Util.mulColor(this.gm.style.field_top, 0.5f), Util.mulColor(this.gm.style.field_btm, 0.5f), 0xff000000, Util.mulColor(this.gm.style.brdr_top, 0.5f), Util.mulColor(this.gm.style.brdr_btm, 0.5f));
|
||||
}
|
||||
|
||||
protected void drawForeground(int x1, int y1, int x2, int y2) {
|
||||
Drawing.txt_draw(x1 + this.text_x, y1 + this.text_y,
|
||||
x1 + this.text_x, y1 + this.text_y,
|
||||
Integer.MAX_VALUE, Integer.MAX_VALUE, this.enabled ? this.gm.style.text_field : Util.mulColor(this.gm.style.text_field, 0.5f), this.getDrawnText());
|
||||
if(this.sel_start >= 0 && this.sel_end != this.sel_start)
|
||||
Drawing.txt_overlay(this.sel_start, this.sel_end, x1 + this.text_x, y1 + this.text_y,
|
||||
x1 + this.text_x, y1 + this.text_y,
|
||||
Integer.MAX_VALUE, Integer.MAX_VALUE, this.enabled ? 0x808080ff : 0x80404040, this.getDrawnText());
|
||||
}
|
||||
|
||||
protected char getNewline() {
|
||||
return ' ';
|
||||
}
|
||||
|
||||
protected String getDrawnText() {
|
||||
return this.text;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public void deleteSpaceToCur() {
|
||||
int num = this.getSpaceBeforeCur() - this.sel_start;
|
||||
if(this.text.length() != 0) {
|
||||
if(this.sel_start != this.sel_end) {
|
||||
this.insertText("");
|
||||
}
|
||||
else {
|
||||
// boolean flag = num < 0;
|
||||
int i = this.sel_start + num; // flag ? this.sel_start + num : this.sel_start;
|
||||
int j = this.sel_start; // flag ? this.sel_start : this.sel_start + num;
|
||||
String s = "";
|
||||
|
||||
if(i >= 0) {
|
||||
s = this.text.substring(0, i);
|
||||
}
|
||||
|
||||
if(j < this.text.length()) {
|
||||
s = s + this.text.substring(j);
|
||||
}
|
||||
|
||||
// this.setText(s);
|
||||
this.text = s;
|
||||
this.updateText();
|
||||
this.sel_start = this.sel_end = this.sel_drag = i;
|
||||
gui_text_update_cur(this.sel_start, true);
|
||||
//
|
||||
// if(flag) {
|
||||
// this.moveCursorBy(num);
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public int getSpaceBeforeCur() {
|
||||
int i = this.sel_start;
|
||||
while(i > 0 && this.text.charAt(i - 1) != ' ') {
|
||||
--i;
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
||||
public int getCursorPos() {
|
||||
return this.sel_start == this.sel_end ? this.sel_start : -1;
|
||||
}
|
||||
}
|
5
client/src/main/java/client/gui/element/FieldAction.java
Normal file
5
client/src/main/java/client/gui/element/FieldAction.java
Normal file
|
@ -0,0 +1,5 @@
|
|||
package client.gui.element;
|
||||
|
||||
public enum FieldAction {
|
||||
FOCUS, UNFOCUS, PREVIOUS, NEXT, FUNCTION, SEND, LINE, FORWARD, BACKWARD;
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
package client.gui.element;
|
||||
|
||||
public interface FieldCallback extends TextCallback<Field> {
|
||||
void use(Field elem, FieldAction value);
|
||||
}
|
|
@ -1,7 +1,7 @@
|
|||
package game.gui.element;
|
||||
package client.gui.element;
|
||||
|
||||
import game.renderer.Drawing;
|
||||
import game.renderer.Drawing.Vec2i;
|
||||
import client.renderer.Drawing;
|
||||
import client.renderer.Drawing.Vec2i;
|
||||
|
||||
public class Fill extends Element {
|
||||
private final boolean left;
|
||||
|
@ -50,8 +50,8 @@ public class Fill extends Element {
|
|||
public void updateText() {
|
||||
Vec2i size = Drawing.getSize(this.text);
|
||||
if(!this.left)
|
||||
this.text_x = (this.size_x - size.xpos) / 2;
|
||||
this.text_x = ((this.size_x - (this.margin_x1 + this.margin_x2)) - size.xpos) / 2;
|
||||
if(!this.top)
|
||||
this.text_y = (this.size_y - size.ypos) / 2;
|
||||
this.text_y = ((this.size_y - (this.margin_y1 + this.margin_y2)) - size.ypos + 1) / 2;
|
||||
}
|
||||
}
|
292
client/src/main/java/client/gui/element/GuiList.java
Executable file
292
client/src/main/java/client/gui/element/GuiList.java
Executable file
|
@ -0,0 +1,292 @@
|
|||
package client.gui.element;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import client.gui.Gui;
|
||||
import client.renderer.Drawing;
|
||||
import client.window.Button;
|
||||
import common.collect.Lists;
|
||||
import common.util.ExtMath;
|
||||
|
||||
public abstract class GuiList<T extends ListEntry> extends Gui
|
||||
{
|
||||
public static final int SCROLLBAR_WIDTH = 6;
|
||||
|
||||
protected final List<T> elements = Lists.newArrayList();
|
||||
|
||||
protected int width;
|
||||
protected int height;
|
||||
|
||||
protected int top;
|
||||
protected int bottom;
|
||||
protected int right;
|
||||
protected int left;
|
||||
protected int mouseX;
|
||||
protected int mouseY;
|
||||
protected int initialClickY = -2;
|
||||
protected float scrollMultiplier;
|
||||
protected float amountScrolled;
|
||||
protected int selectedElement = -1;
|
||||
protected long lastClicked;
|
||||
|
||||
public abstract int getSlotHeight();
|
||||
|
||||
protected boolean isScrollbarRight()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public void setDimensions(int widthIn, int heightIn, int topIn, int bottomIn)
|
||||
{
|
||||
this.width = widthIn;
|
||||
this.height = heightIn;
|
||||
this.top = topIn;
|
||||
this.bottom = bottomIn;
|
||||
this.left = 0;
|
||||
this.right = widthIn;
|
||||
}
|
||||
|
||||
public void init(int width, int height) {
|
||||
|
||||
this.selectedElement = -1;
|
||||
}
|
||||
|
||||
public void setSlotXBoundsFromLeft(int leftIn)
|
||||
{
|
||||
this.left = leftIn;
|
||||
this.right = leftIn + this.width;
|
||||
}
|
||||
|
||||
public final T getListEntry(int index) {
|
||||
return this.elements.get(index);
|
||||
}
|
||||
|
||||
public final T getSelected() {
|
||||
return this.selectedElement < 0 ? null : this.elements.get(this.selectedElement);
|
||||
}
|
||||
|
||||
public final int getSize() {
|
||||
return this.elements.size();
|
||||
}
|
||||
|
||||
public final void setSelected(int index) {
|
||||
this.selectedElement = index;
|
||||
}
|
||||
|
||||
protected int getContentHeight()
|
||||
{
|
||||
return this.getSize() * this.getSlotHeight();
|
||||
}
|
||||
|
||||
public int getSlotIndexFromScreenCoords(int x, int y)
|
||||
{
|
||||
int x1 = this.left + (this.isScrollbarRight() ? 0 : SCROLLBAR_WIDTH);
|
||||
int x2 = this.left + (this.isScrollbarRight() ? this.width - SCROLLBAR_WIDTH : this.width);
|
||||
int y1 = y - this.top + (int)this.amountScrolled - 4;
|
||||
int idx = y1 / this.getSlotHeight();
|
||||
return this.isInList(x, y) && x >= x1 && x <= x2 && idx >= 0 && y1 >= 0 && idx < this.getSize() ? idx : -1;
|
||||
}
|
||||
|
||||
protected boolean isInList(int x, int y)
|
||||
{
|
||||
return this.isScrollbarRight() ? x < this.width - SCROLLBAR_WIDTH : x >= SCROLLBAR_WIDTH;
|
||||
}
|
||||
|
||||
protected final boolean isSelected(int slotIndex)
|
||||
{
|
||||
return slotIndex == this.selectedElement;
|
||||
}
|
||||
|
||||
protected void bindAmountScrolled()
|
||||
{
|
||||
this.amountScrolled = ExtMath.clampf(this.amountScrolled, 0.0F, (float)this.getMaxScroll());
|
||||
}
|
||||
|
||||
public int getMaxScroll()
|
||||
{
|
||||
return Math.max(0, this.getContentHeight() - (this.bottom - this.top - 4));
|
||||
}
|
||||
|
||||
public int getAmountScrolled()
|
||||
{
|
||||
return (int)this.amountScrolled;
|
||||
}
|
||||
|
||||
public boolean isMouseYWithinSlotBounds(int y)
|
||||
{
|
||||
return y >= this.top && y <= this.bottom && this.mouseX >= this.left && this.mouseX <= this.right;
|
||||
}
|
||||
|
||||
public void scrollBy(int amount)
|
||||
{
|
||||
this.amountScrolled += (float)amount;
|
||||
this.bindAmountScrolled();
|
||||
this.initialClickY = -2;
|
||||
}
|
||||
|
||||
public void draw()
|
||||
{
|
||||
int mouseXIn = this.gm.mouse_x;
|
||||
int mouseYIn = this.gm.mouse_y;
|
||||
this.mouseX = mouseXIn;
|
||||
this.mouseY = mouseYIn;
|
||||
this.drawBackground();
|
||||
this.bindAmountScrolled();
|
||||
|
||||
Drawing.drawScaled(this.gm, Gui.BACKGROUND, 0, this.top, this.gm.fb_x, this.bottom - this.top, 0xff7f7f7f);
|
||||
|
||||
int x = this.left + (this.isScrollbarRight() ? 0 : SCROLLBAR_WIDTH);
|
||||
int y = this.top + 4 - (int)this.amountScrolled;
|
||||
|
||||
int size = this.getSize();
|
||||
boolean canHover = this.clicked(mouseXIn, mouseYIn) == null;
|
||||
|
||||
for (int z = 0; z < size; z++)
|
||||
{
|
||||
int y1 = y + z * this.getSlotHeight();
|
||||
int h = this.getSlotHeight() - 4;
|
||||
|
||||
Drawing.drawRectBorder(x, y1 - 2, this.width - SCROLLBAR_WIDTH, this.getSlotHeight(), this.isSelected(z) ? this.gm.style.fill_btm : this.gm.style.fill_top, this.isSelected(z) ? 0xffffffff : 0xff000000, this.gm.style.brdr_top, this.gm.style.brdr_btm);
|
||||
|
||||
boolean hover = canHover && this.getSlotIndexFromScreenCoords(mouseXIn, mouseYIn) == z;
|
||||
this.getListEntry(z).draw(x + 2, y1, this.width - SCROLLBAR_WIDTH - 4, this.getSlotHeight() - 4, mouseXIn - x - 2, mouseYIn - y1, hover);
|
||||
if(hover)
|
||||
Drawing.drawRect(x, y1 - 2, this.width - SCROLLBAR_WIDTH, this.getSlotHeight(), Gui.HOVER_COLOR);
|
||||
}
|
||||
|
||||
Drawing.drawScaled(this.gm, Gui.BACKGROUND, 0, 0, this.gm.fb_x, this.top, 0xffffffff);
|
||||
Drawing.drawScaled(this.gm, Gui.BACKGROUND, 0, this.bottom, this.gm.fb_x, this.height - this.bottom, 0xffffffff);
|
||||
Drawing.drawRect(-1, -1, this.gm.fb_x + 2, this.top + 1, 0, this.gm.style.brdr_top, this.gm.style.brdr_btm);
|
||||
Drawing.drawRect(-1, this.bottom, this.gm.fb_x + 2, this.height - this.bottom + 1, 0, this.gm.style.brdr_top, this.gm.style.brdr_btm);
|
||||
|
||||
int edge = 2;
|
||||
Drawing.drawGradient(0, this.top, this.gm.fb_x, edge, 0xff000000, 0x00000000);
|
||||
Drawing.drawGradient(0, this.bottom - edge, this.gm.fb_x, edge, 0x00000000, 0xff000000);
|
||||
|
||||
int max = this.getMaxScroll();
|
||||
|
||||
if (max > 0)
|
||||
{
|
||||
int barHeight = (this.bottom - this.top) * (this.bottom - this.top) / this.getContentHeight();
|
||||
barHeight = ExtMath.clampi(barHeight, 32, this.bottom - this.top - 8);
|
||||
int scrollX = this.isScrollbarRight() ? this.width - SCROLLBAR_WIDTH : 0;
|
||||
int scrollY = (int)this.amountScrolled * (this.bottom - this.top - barHeight) / max + this.top;
|
||||
if(scrollY < this.top)
|
||||
scrollY = this.top;
|
||||
Drawing.drawRect(scrollX, this.top, SCROLLBAR_WIDTH, this.bottom - this.top, 0xff000000);
|
||||
Drawing.drawGradient(scrollX, scrollY, SCROLLBAR_WIDTH, barHeight, this.gm.style.fill_top, this.gm.style.fill_btm, this.gm.style.brdr_top, this.gm.style.brdr_btm);
|
||||
}
|
||||
|
||||
super.draw();
|
||||
}
|
||||
|
||||
public void handleMouseInput()
|
||||
{
|
||||
if (this.isMouseYWithinSlotBounds(this.mouseY))
|
||||
{
|
||||
if (this.initialClickY == -1)
|
||||
{
|
||||
boolean flag1 = true;
|
||||
|
||||
if (this.mouseY >= this.top && this.mouseY <= this.bottom)
|
||||
{
|
||||
int j2 = (this.isScrollbarRight() ? 0 : SCROLLBAR_WIDTH);
|
||||
int k2 = (this.isScrollbarRight() ? this.width - SCROLLBAR_WIDTH : this.width);
|
||||
int l2 = this.mouseY - this.top + (int)this.amountScrolled - 4;
|
||||
int i1 = l2 / this.getSlotHeight();
|
||||
|
||||
if (i1 < this.getSize() && this.mouseX >= j2 && this.mouseX <= k2 && i1 >= 0 && l2 >= 0)
|
||||
{
|
||||
}
|
||||
else if (this.mouseX >= j2 && this.mouseX <= k2 && l2 < 0)
|
||||
{
|
||||
flag1 = false;
|
||||
}
|
||||
|
||||
int i3 = this.isScrollbarRight() ? this.width - SCROLLBAR_WIDTH : 0;
|
||||
int j1 = i3 + SCROLLBAR_WIDTH;
|
||||
|
||||
if (this.mouseX >= i3 && this.mouseX <= j1)
|
||||
{
|
||||
this.scrollMultiplier = -1.0F;
|
||||
int k1 = this.getMaxScroll();
|
||||
|
||||
if (k1 < 1)
|
||||
{
|
||||
k1 = 1;
|
||||
}
|
||||
|
||||
int l1 = (int)((float)((this.bottom - this.top) * (this.bottom - this.top)) / (float)this.getContentHeight());
|
||||
l1 = ExtMath.clampi(l1, 32, this.bottom - this.top - 8);
|
||||
this.scrollMultiplier /= (float)(this.bottom - this.top - l1) / (float)k1;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.scrollMultiplier = 1.0F;
|
||||
}
|
||||
|
||||
if (flag1)
|
||||
{
|
||||
this.initialClickY = this.mouseY;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.initialClickY = -2;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.initialClickY = -2;
|
||||
}
|
||||
}
|
||||
else if (this.initialClickY >= 0)
|
||||
{
|
||||
this.amountScrolled -= (float)(this.mouseY - this.initialClickY) * this.scrollMultiplier;
|
||||
this.initialClickY = this.mouseY;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void mouse(Button btn, int x, int y, boolean ctrl, boolean shift)
|
||||
{
|
||||
super.mouse(btn, x, y, ctrl, shift);
|
||||
if (this.isMouseYWithinSlotBounds(y) && this.clicked(x, y) == null)
|
||||
{
|
||||
int i = this.getSlotIndexFromScreenCoords(x, y);
|
||||
|
||||
if (i >= 0)
|
||||
{
|
||||
int x1 = this.left + (this.isScrollbarRight() ? 0 : SCROLLBAR_WIDTH) + 2;
|
||||
int y1 = this.top + 4 - this.getAmountScrolled() + i * this.getSlotHeight();
|
||||
int mx = x - x1;
|
||||
int my = y - y1;
|
||||
|
||||
boolean flag = i == this.selectedElement && System.currentTimeMillis() - this.lastClicked < (long)this.gm.dclickDelay;
|
||||
this.selectedElement = i;
|
||||
this.lastClicked = System.currentTimeMillis();
|
||||
|
||||
this.getListEntry(i).select(flag, mx, my);
|
||||
}
|
||||
}
|
||||
if(btn == Button.MOUSE_LEFT && this.clicked(x, y) == null)
|
||||
this.handleMouseInput();
|
||||
}
|
||||
|
||||
public void mouserel(Button btn, int x, int y) {
|
||||
super.mouserel(btn, x, y);
|
||||
if(btn == Button.MOUSE_LEFT)
|
||||
this.initialClickY = -1;
|
||||
}
|
||||
|
||||
public void scroll(int scr_x, int scr_y, int x, int y, boolean ctrl, boolean shift) {
|
||||
super.scroll(scr_x, scr_y, x, y, ctrl, shift);
|
||||
if(scr_y != 0 && this.clicked(x, y) == null)
|
||||
this.amountScrolled -= (float)(ExtMath.clampi(scr_y, -1, 1) * this.getSlotHeight() / 2);
|
||||
}
|
||||
|
||||
public void drag(int x, int y) {
|
||||
super.drag(x, y);
|
||||
if(this.selected == null && Button.MOUSE_LEFT.isDown() && (this.initialClickY != -1 || this.clicked(x, y) == null))
|
||||
this.handleMouseInput();
|
||||
}
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
package game.gui.element;
|
||||
package client.gui.element;
|
||||
|
||||
import game.renderer.Drawing;
|
||||
import client.renderer.Drawing;
|
||||
|
||||
public class InventoryButton extends Element {
|
||||
public InventoryButton(int x, int y, int w, int h) {
|
47
client/src/main/java/client/gui/element/Label.java
Normal file
47
client/src/main/java/client/gui/element/Label.java
Normal file
|
@ -0,0 +1,47 @@
|
|||
package client.gui.element;
|
||||
|
||||
import client.renderer.Drawing;
|
||||
import common.util.Util;
|
||||
|
||||
public class Label extends Fill {
|
||||
public static final int LABEL_HEIGHT = 14;
|
||||
|
||||
public Label(int x, int y, int w, int h, String text, boolean top, boolean left) {
|
||||
super(x, y, w, h <= 0 ? LABEL_HEIGHT : h, text, top, left);
|
||||
}
|
||||
|
||||
public Label(int x, int y, int w, int h, String text, boolean left) {
|
||||
super(x, y, w, h <= 0 ? LABEL_HEIGHT : h, text, left);
|
||||
}
|
||||
|
||||
public Label(int x, int y, int w, int h, String text) {
|
||||
super(x, y, w, h <= 0 ? LABEL_HEIGHT : h, text);
|
||||
}
|
||||
|
||||
public Label(int x, int y, int w, String text, boolean top, boolean left) {
|
||||
super(x, y - LABEL_HEIGHT, w, LABEL_HEIGHT, text, top, left);
|
||||
}
|
||||
|
||||
public Label(int x, int y, int w, String text, boolean left) {
|
||||
super(x, y - LABEL_HEIGHT, w, LABEL_HEIGHT, text, left);
|
||||
}
|
||||
|
||||
public Label(int x, int y, int w, String text) {
|
||||
super(x, y - LABEL_HEIGHT, w, LABEL_HEIGHT, text);
|
||||
}
|
||||
|
||||
protected void drawBackground() {
|
||||
}
|
||||
|
||||
protected void drawForeground(int x1, int y1, int x2, int y2) {
|
||||
Drawing.drawText(this.text, x1 + this.text_x, y1 + this.text_y, this.enabled ? this.gm.style.text_label : Util.mulColor(this.gm.style.text_label, 0.5f));
|
||||
}
|
||||
|
||||
protected int getMarginX() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
protected int getMarginY() {
|
||||
return 0;
|
||||
}
|
||||
}
|
7
client/src/main/java/client/gui/element/ListEntry.java
Normal file
7
client/src/main/java/client/gui/element/ListEntry.java
Normal file
|
@ -0,0 +1,7 @@
|
|||
package client.gui.element;
|
||||
|
||||
public interface ListEntry
|
||||
{
|
||||
void draw(int x, int y, int width, int height, int mouseX, int mouseY, boolean hovered);
|
||||
void select(boolean dclick, int mx, int my);
|
||||
}
|
40
client/src/main/java/client/gui/element/MultiLabel.java
Normal file
40
client/src/main/java/client/gui/element/MultiLabel.java
Normal file
|
@ -0,0 +1,40 @@
|
|||
package client.gui.element;
|
||||
|
||||
import client.gui.Font;
|
||||
import client.renderer.Drawing;
|
||||
import common.util.Util;
|
||||
|
||||
public class MultiLabel extends Fill {
|
||||
private String[] lines;
|
||||
|
||||
public MultiLabel(int x, int y, int w, int h, String text, boolean top) {
|
||||
super(x, y, w, h, text, top, true);
|
||||
}
|
||||
|
||||
public MultiLabel(int x, int y, int w, int h, String text) {
|
||||
super(x, y, w, h, text, false, true);
|
||||
}
|
||||
|
||||
public void setText(String str) {
|
||||
super.setText(str);
|
||||
this.lines = str.split("\n", -1);
|
||||
}
|
||||
|
||||
protected void drawBackground() {
|
||||
}
|
||||
|
||||
protected void drawForeground(int x1, int y1, int x2, int y2) {
|
||||
int color = this.enabled ? this.gm.style.text_label : Util.mulColor(this.gm.style.text_label, 0.5f);
|
||||
for(int z = 0; z < this.lines.length; z++) {
|
||||
Drawing.drawTextCentered(this.lines[z], x1 + x2 / 2, y1 + this.text_y + z * Font.YGLYPH, color);
|
||||
}
|
||||
}
|
||||
|
||||
protected int getMarginX() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
protected int getMarginY() {
|
||||
return 0;
|
||||
}
|
||||
}
|
|
@ -1,17 +1,17 @@
|
|||
package game.gui.element;
|
||||
package client.gui.element;
|
||||
|
||||
import game.Game;
|
||||
import game.gui.Gui;
|
||||
import game.renderer.Drawing;
|
||||
import game.util.Util;
|
||||
import client.Client;
|
||||
import client.gui.Gui;
|
||||
import client.renderer.Drawing;
|
||||
import common.util.Util;
|
||||
|
||||
public class NavButton extends ActButton {
|
||||
private final Gui navGui;
|
||||
|
||||
public NavButton(int x, int y, int w, int h, Gui gui, String text) {
|
||||
super(x, y, w, h, new Callback() {
|
||||
public void use(ActButton elem, Mode action) {
|
||||
Game.getGame().displayGuiScreen(gui);
|
||||
super(x, y, w, h, new ButtonCallback() {
|
||||
public void use(ActButton elem, PressType action) {
|
||||
Client.CLIENT.displayGuiScreen(gui);
|
||||
}
|
||||
}, text);
|
||||
this.navGui = gui;
|
17
client/src/main/java/client/gui/element/PasswordField.java
Normal file
17
client/src/main/java/client/gui/element/PasswordField.java
Normal file
|
@ -0,0 +1,17 @@
|
|||
package client.gui.element;
|
||||
|
||||
import common.util.Util;
|
||||
|
||||
public class PasswordField extends Field {
|
||||
public PasswordField(int x, int y, int w, int h, int cap, FieldCallback callback, String text) {
|
||||
super(x, y, w, h, cap, callback, text);
|
||||
}
|
||||
|
||||
protected String getDrawnText() {
|
||||
return Util.repeatString("*", this.text.length());
|
||||
}
|
||||
|
||||
protected boolean canCopy() {
|
||||
return false;
|
||||
}
|
||||
}
|
5
client/src/main/java/client/gui/element/PressType.java
Normal file
5
client/src/main/java/client/gui/element/PressType.java
Normal file
|
@ -0,0 +1,5 @@
|
|||
package client.gui.element;
|
||||
|
||||
public enum PressType {
|
||||
PRIMARY, SECONDARY, TERTIARY;
|
||||
}
|
|
@ -1,12 +1,12 @@
|
|||
package game.gui.element;
|
||||
package client.gui.element;
|
||||
|
||||
import game.renderer.Drawing;
|
||||
import game.util.Util;
|
||||
import client.renderer.Drawing;
|
||||
import common.util.Util;
|
||||
|
||||
public class SelectableButton extends ActButton {
|
||||
private boolean selected;
|
||||
|
||||
public SelectableButton(int x, int y, int w, int h, Callback callback, String text, boolean selected) {
|
||||
public SelectableButton(int x, int y, int w, int h, ButtonCallback callback, String text, boolean selected) {
|
||||
super(x, y, w, h, callback, text);
|
||||
this.selected = selected;
|
||||
}
|
|
@ -1,23 +1,15 @@
|
|||
package game.gui.element;
|
||||
package client.gui.element;
|
||||
|
||||
import game.renderer.Drawing;
|
||||
import game.util.ExtMath;
|
||||
import game.util.Formatter;
|
||||
import game.util.Util;
|
||||
import game.window.Button;
|
||||
import client.gui.Formatter;
|
||||
import client.renderer.Drawing;
|
||||
import client.window.Button;
|
||||
import common.util.ExtMath;
|
||||
import common.util.Util;
|
||||
|
||||
public class Slider extends Element {
|
||||
public static interface Callback {
|
||||
void use(Slider elem, int value);
|
||||
}
|
||||
private static final int SLIDER_WIDTH = 8;
|
||||
|
||||
public static interface FloatCallback {
|
||||
void use(Slider elem, float value);
|
||||
}
|
||||
|
||||
private static final int SLIDER_WIDTH = 10;
|
||||
|
||||
private final Callback func;
|
||||
private final SliderCallback func;
|
||||
private final int def;
|
||||
private final int min;
|
||||
private final int max;
|
||||
|
@ -27,9 +19,9 @@ public class Slider extends Element {
|
|||
private int value;
|
||||
private int position;
|
||||
|
||||
public Slider(int x, int y, int w, int h, int prec, int min, int max, int def, int init, Callback callback, Formatter<Slider> formatter) {
|
||||
public Slider(int x, int y, int w, int h, int prec, int min, int max, int def, int init, SliderCallback callback, Formatter<Slider> formatter) {
|
||||
super(x, y, w, h, formatter);
|
||||
this.handle = ((this.size_y * SLIDER_WIDTH) / 24) & ~1;
|
||||
this.handle = ((this.size_y * SLIDER_WIDTH) / BASE_HEIGHT) & ~1;
|
||||
this.func = callback;
|
||||
this.precision = prec;
|
||||
this.min = min;
|
||||
|
@ -40,7 +32,7 @@ public class Slider extends Element {
|
|||
this.formatText();
|
||||
}
|
||||
|
||||
public Slider(int x, int y, int w, int h, int prec, int min, int max, int def, int init, Callback callback, final String text) {
|
||||
public Slider(int x, int y, int w, int h, int prec, int min, int max, int def, int init, SliderCallback callback, final String text) {
|
||||
this(x, y, w, h, prec, min, max, def, init, callback, new Formatter<Slider>() {
|
||||
public String use(Slider elem) {
|
||||
return String.format("%s: %d", text, elem.value);
|
||||
|
@ -48,7 +40,7 @@ public class Slider extends Element {
|
|||
});
|
||||
}
|
||||
|
||||
public Slider(int x, int y, int w, int h, int prec, int min, int max, int def, int init, Callback callback, final String text, final String unit) {
|
||||
public Slider(int x, int y, int w, int h, int prec, int min, int max, int def, int init, SliderCallback callback, final String text, final String unit) {
|
||||
this(x, y, w, h, prec, min, max, def, init, callback, new Formatter<Slider>() {
|
||||
private final String format = unit.isEmpty() ? "%s: %d" : "%s: %d %s";
|
||||
|
||||
|
@ -58,15 +50,15 @@ public class Slider extends Element {
|
|||
});
|
||||
}
|
||||
|
||||
public Slider(int x, int y, int w, int h, int prec, float min, float max, float def, float init, final FloatCallback callback, Formatter<Slider> formatter) {
|
||||
this(x, y, w, h, prec, (int)(min * 1000.0f), (int)(max * 1000.0f), (int)(def * 1000.0f), (int)(init * 1000.0f), new Callback() {
|
||||
public Slider(int x, int y, int w, int h, int prec, float min, float max, float def, float init, final SliderFloatCallback callback, Formatter<Slider> formatter) {
|
||||
this(x, y, w, h, prec, (int)(min * 1000.0f), (int)(max * 1000.0f), (int)(def * 1000.0f), (int)(init * 1000.0f), new SliderCallback() {
|
||||
public void use(Slider elem, int value) {
|
||||
callback.use(elem, (float)value / 1000.0f);
|
||||
}
|
||||
}, formatter);
|
||||
}
|
||||
|
||||
public Slider(int x, int y, int w, int h, final int prec, float min, float max, float def, float init, FloatCallback callback, final String text, final String unit) {
|
||||
public Slider(int x, int y, int w, int h, final int prec, float min, float max, float def, float init, SliderFloatCallback callback, final String text, final String unit) {
|
||||
this(x, y, w, h, prec < 0 ? 0 : prec, min, max, def, init, callback, new Formatter<Slider>() {
|
||||
private final String format = "%s: " + (prec <= 0 ? "%d" : ("%." + prec + "f")) + (unit.isEmpty() ? "" : " %s");
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
package client.gui.element;
|
||||
|
||||
public interface SliderCallback {
|
||||
void use(Slider elem, int value);
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
package client.gui.element;
|
||||
|
||||
public interface SliderFloatCallback {
|
||||
void use(Slider elem, float value);
|
||||
}
|
|
@ -1,22 +1,18 @@
|
|||
package game.gui.element;
|
||||
package client.gui.element;
|
||||
|
||||
import game.util.Displayable;
|
||||
import game.util.Formatter;
|
||||
import game.util.Util;
|
||||
import game.window.Button;
|
||||
import client.gui.Formatter;
|
||||
import client.window.Button;
|
||||
import common.util.Displayable;
|
||||
import common.util.Util;
|
||||
|
||||
public class Switch<T> extends Element {
|
||||
public static interface Callback<T> {
|
||||
void use(Switch<T> elem, T value);
|
||||
}
|
||||
|
||||
private final Callback<T> func;
|
||||
private final SwitchCallback<T> func;
|
||||
private final T[] values;
|
||||
private final int def;
|
||||
|
||||
private int value;
|
||||
|
||||
public Switch(int x, int y, int w, int h, T[] values, T def, T init, Callback<T> callback, Formatter<Switch<T>> formatter) {
|
||||
public Switch(int x, int y, int w, int h, T[] values, T def, T init, SwitchCallback<T> callback, Formatter<Switch<T>> formatter) {
|
||||
super(x, y, w, h, formatter);
|
||||
this.func = callback;
|
||||
this.values = values;
|
||||
|
@ -25,11 +21,11 @@ public class Switch<T> extends Element {
|
|||
this.formatText();
|
||||
}
|
||||
|
||||
public Switch(int x, int y, int w, int h, T[] values, T def, T init, Callback<T> callback, final String text) {
|
||||
public Switch(int x, int y, int w, int h, T[] values, T def, T init, SwitchCallback<T> callback, final String text) {
|
||||
this(x, y, w, h, values, def, init, callback, new Formatter<Switch<T>>() {
|
||||
public String use(Switch<T> elem) {
|
||||
T value = elem.getValue();
|
||||
return String.format("%s: %s", text, value instanceof Displayable ? ((Displayable)value).getDisplay() : value.toString());
|
||||
return String.format("%s: %s", text, value instanceof Displayable disp ? disp.getDisplay() : value.toString());
|
||||
}
|
||||
});
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
package client.gui.element;
|
||||
|
||||
public interface SwitchCallback<T> {
|
||||
void use(Switch<T> elem, T value);
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue