semi working Store
This commit is contained in:
+10
-10
@@ -1,12 +1,12 @@
|
||||
<factorypath>
|
||||
<factorypathentry kind="EXTJAR" id="/Users/klestiselimaj/.gradle/caches/modules-2/files-2.1/io.github.llamalad7/mixinextras-fabric/0.4.1/8d1a9e96afb990367fa1f904d17580d164da72e3/mixinextras-fabric-0.4.1.jar" enabled="true" runInBatchMode="false"/>
|
||||
<factorypathentry kind="EXTJAR" id="/Users/klestiselimaj/.gradle/caches/modules-2/files-2.1/org.ow2.asm/asm-analysis/9.7.1/f97a3b319f0ed6a8cd944dc79060d3912a28985f/asm-analysis-9.7.1.jar" enabled="true" runInBatchMode="false"/>
|
||||
<factorypathentry kind="EXTJAR" id="/Users/klestiselimaj/.gradle/caches/modules-2/files-2.1/net.fabricmc/fabric-mixin-compile-extensions/0.6.0/6fda0c85c419f0a259da017a1424f27507eb30f0/fabric-mixin-compile-extensions-0.6.0.jar" enabled="true" runInBatchMode="false"/>
|
||||
<factorypathentry kind="EXTJAR" id="/Users/klestiselimaj/.gradle/caches/modules-2/files-2.1/net.fabricmc/mapping-io/0.2.1/2a1aeedce104191bbb9e39e26abfbfeaf9b0590b/mapping-io-0.2.1.jar" enabled="true" runInBatchMode="false"/>
|
||||
<factorypathentry kind="EXTJAR" id="/Users/klestiselimaj/.gradle/caches/modules-2/files-2.1/org.ow2.asm/asm-tree/9.7.1/3a53139787663b139de76b627fca0084ab60d32c/asm-tree-9.7.1.jar" enabled="true" runInBatchMode="false"/>
|
||||
<factorypathentry kind="EXTJAR" id="/Users/klestiselimaj/.gradle/caches/fabric-loom/1.21.4/net.fabricmc.yarn.1_21_4.1.21.4+build.7-v2/mappings.jar" enabled="true" runInBatchMode="false"/>
|
||||
<factorypathentry kind="EXTJAR" id="/Users/klestiselimaj/.gradle/caches/modules-2/files-2.1/net.fabricmc/sponge-mixin/0.15.4+mixin.0.8.7/6a12aacc794f1078458433116e9ed42c1cc98096/sponge-mixin-0.15.4+mixin.0.8.7.jar" enabled="true" runInBatchMode="false"/>
|
||||
<factorypathentry kind="EXTJAR" id="/Users/klestiselimaj/.gradle/caches/modules-2/files-2.1/org.ow2.asm/asm/9.7.1/f0ed132a49244b042cd0e15702ab9f2ce3cc8436/asm-9.7.1.jar" enabled="true" runInBatchMode="false"/>
|
||||
<factorypathentry kind="EXTJAR" id="/Users/klestiselimaj/.gradle/caches/modules-2/files-2.1/org.ow2.asm/asm-util/9.7.1/9e23359b598ec6b74b23e53110dd5c577adf2243/asm-util-9.7.1.jar" enabled="true" runInBatchMode="false"/>
|
||||
<factorypathentry kind="EXTJAR" id="/Users/klestiselimaj/.gradle/caches/modules-2/files-2.1/org.ow2.asm/asm-commons/9.7.1/406c6a2225cfe1819f102a161e54cc16a5c24f75/asm-commons-9.7.1.jar" enabled="true" runInBatchMode="false"/>
|
||||
<factorypathentry kind="EXTJAR" id="/home/leo/.gradle/caches/modules-2/files-2.1/io.github.llamalad7/mixinextras-fabric/0.4.1/8d1a9e96afb990367fa1f904d17580d164da72e3/mixinextras-fabric-0.4.1.jar" enabled="true" runInBatchMode="false"/>
|
||||
<factorypathentry kind="EXTJAR" id="/home/leo/.gradle/caches/modules-2/files-2.1/org.ow2.asm/asm-util/9.7.1/9e23359b598ec6b74b23e53110dd5c577adf2243/asm-util-9.7.1.jar" enabled="true" runInBatchMode="false"/>
|
||||
<factorypathentry kind="EXTJAR" id="/home/leo/.gradle/caches/modules-2/files-2.1/org.ow2.asm/asm-tree/9.7.1/3a53139787663b139de76b627fca0084ab60d32c/asm-tree-9.7.1.jar" enabled="true" runInBatchMode="false"/>
|
||||
<factorypathentry kind="EXTJAR" id="/home/leo/.gradle/caches/modules-2/files-2.1/net.fabricmc/fabric-mixin-compile-extensions/0.6.0/6fda0c85c419f0a259da017a1424f27507eb30f0/fabric-mixin-compile-extensions-0.6.0.jar" enabled="true" runInBatchMode="false"/>
|
||||
<factorypathentry kind="EXTJAR" id="/home/leo/.gradle/caches/fabric-loom/1.21.4/net.fabricmc.yarn.1_21_4.1.21.4+build.7-v2/mappings.jar" enabled="true" runInBatchMode="false"/>
|
||||
<factorypathentry kind="EXTJAR" id="/home/leo/.gradle/caches/modules-2/files-2.1/org.ow2.asm/asm-analysis/9.7.1/f97a3b319f0ed6a8cd944dc79060d3912a28985f/asm-analysis-9.7.1.jar" enabled="true" runInBatchMode="false"/>
|
||||
<factorypathentry kind="EXTJAR" id="/home/leo/.gradle/caches/modules-2/files-2.1/net.fabricmc/sponge-mixin/0.15.4+mixin.0.8.7/6a12aacc794f1078458433116e9ed42c1cc98096/sponge-mixin-0.15.4+mixin.0.8.7.jar" enabled="true" runInBatchMode="false"/>
|
||||
<factorypathentry kind="EXTJAR" id="/home/leo/.gradle/caches/modules-2/files-2.1/org.ow2.asm/asm-commons/9.7.1/406c6a2225cfe1819f102a161e54cc16a5c24f75/asm-commons-9.7.1.jar" enabled="true" runInBatchMode="false"/>
|
||||
<factorypathentry kind="EXTJAR" id="/home/leo/.gradle/caches/modules-2/files-2.1/org.ow2.asm/asm/9.7.1/f0ed132a49244b042cd0e15702ab9f2ce3cc8436/asm-9.7.1.jar" enabled="true" runInBatchMode="false"/>
|
||||
<factorypathentry kind="EXTJAR" id="/home/leo/.gradle/caches/modules-2/files-2.1/net.fabricmc/mapping-io/0.2.1/2a1aeedce104191bbb9e39e26abfbfeaf9b0590b/mapping-io-0.2.1.jar" enabled="true" runInBatchMode="false"/>
|
||||
</factorypath>
|
||||
|
||||
@@ -96,6 +96,16 @@ public class Auth {
|
||||
}
|
||||
break;
|
||||
|
||||
case "successful_transaction":
|
||||
String cloak = parser.getStringOrNull("cloak");
|
||||
String hat = parser.getStringOrNull("hat");
|
||||
if (cloak != null) {
|
||||
Cloaks.availableCloaks.add(cloak);
|
||||
}
|
||||
if (hat != null) {
|
||||
Hats.availableHats.add(hat);
|
||||
}
|
||||
|
||||
default:
|
||||
if (parser.error != null) {
|
||||
SaturnClient.LOGGER.error("Error from the server: " + parser.error);
|
||||
@@ -218,4 +228,12 @@ public class Auth {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void buyCloak(String name) {
|
||||
try {
|
||||
Network.write("buy_cloak@cloak=" + name);
|
||||
} catch (Exception e) {
|
||||
SaturnClient.LOGGER.error("Request failed", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,6 +43,11 @@ public class SaturnParser {
|
||||
}
|
||||
}
|
||||
|
||||
public String getStringOrNull(String i) throws IOException {
|
||||
String val = params.get(i);
|
||||
return val;
|
||||
}
|
||||
|
||||
public boolean getBool(String i) throws IOException {
|
||||
String val = params.get(i);
|
||||
if (val != null) {
|
||||
|
||||
@@ -20,6 +20,7 @@ import org.saturnclient.saturnclient.SaturnClient;
|
||||
* Originally created by IIpho3nix and modified for Saturn Client by leo.
|
||||
*/
|
||||
public class Cloaks {
|
||||
public static final String[] ALL_CLOAKS = { "glitch", "mercedes_flow", };
|
||||
private static final String[] ANIMATED_CLOAKS = { "glitch", "mercedes_flow" };
|
||||
|
||||
private static final String CLOAKS_RESOURCE_PATH = "assets/saturnclient/textures/cloaks/";
|
||||
@@ -48,6 +49,17 @@ public class Cloaks {
|
||||
SaturnClient.LOGGER.info("Cloak set to " + cloakName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets cloak of the current player
|
||||
*
|
||||
* @param cloakName Name of the cloak file to load
|
||||
*/
|
||||
public static void setCloak(String cloakName) {
|
||||
if (availableCloaks.contains(cloakName)) {
|
||||
setCloak(Auth.uuid, cloakName);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles loading and caching of a new cloak texture, without connecting to the
|
||||
* server.
|
||||
|
||||
@@ -31,45 +31,45 @@ public class Element {
|
||||
public void charTyped(char typedChar) {
|
||||
}
|
||||
|
||||
public final Element dimensions(int width, int height) {
|
||||
public Element dimensions(int width, int height) {
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public final Element position(int x, int y) {
|
||||
public Element position(int x, int y) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public final Element centerHorizontal(int w, int h, int offsetX, int offsetY) {
|
||||
public Element centerHorizontal(int w, int h, int offsetX, int offsetY) {
|
||||
this.x = (w - (int) (width * scale)) / 2 + offsetX;
|
||||
this.y = offsetY;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public final Element center(int w, int h) {
|
||||
public Element center(int w, int h) {
|
||||
this.centerOffset(w, h, 0, 0);
|
||||
return this;
|
||||
}
|
||||
|
||||
public final Element centerOffset(int w, int h, int offsetX, int offsetY) {
|
||||
public Element centerOffset(int w, int h, int offsetX, int offsetY) {
|
||||
this.x = (w - (int) (width * scale)) / 2 + offsetX;
|
||||
this.y = (h - (int) (height * scale)) / 2 + offsetY;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public final Element animation(Animation animation) {
|
||||
public Element animation(Animation animation) {
|
||||
this.animation = animation;
|
||||
return this;
|
||||
}
|
||||
|
||||
public final Element animation(Animation animation, Function<Double, Double> curve) {
|
||||
public Element animation(Animation animation, Function<Double, Double> curve) {
|
||||
this.animation = animation;
|
||||
this.curve = curve;
|
||||
return this;
|
||||
|
||||
@@ -13,6 +13,7 @@ import org.saturnclient.ui2.screens.CloakMenu;
|
||||
import org.saturnclient.ui2.screens.ConfigEditor;
|
||||
import org.saturnclient.ui2.screens.HatMenu;
|
||||
import org.saturnclient.ui2.screens.ModMenu;
|
||||
import org.saturnclient.ui2.screens.Store;
|
||||
|
||||
import net.minecraft.client.render.RenderLayer;
|
||||
import net.minecraft.util.Identifier;
|
||||
@@ -62,7 +63,11 @@ public class Sidebar extends Element {
|
||||
|
||||
new Sidebar.SidebarComponent(Textures.CLOSE, () -> {
|
||||
onClose.run();
|
||||
}, true)
|
||||
}, true),
|
||||
|
||||
new Sidebar.SidebarComponent(Textures.STORE, () -> {
|
||||
SaturnClient.client.setScreen(new Store());
|
||||
}, true),
|
||||
};
|
||||
int active = 0;
|
||||
|
||||
|
||||
@@ -61,16 +61,14 @@ public class Scroll extends Element {
|
||||
|
||||
public void draw(Element element) {
|
||||
children.add(element);
|
||||
}
|
||||
|
||||
if (element.width > width) {
|
||||
width = element.width;
|
||||
@Override
|
||||
public Element dimensions(int width, int height) {
|
||||
for (Element element : children) {
|
||||
maxScroll = Math.max(maxScroll, element.y + element.height - height);
|
||||
}
|
||||
|
||||
if (element.height > height) {
|
||||
height = element.height;
|
||||
}
|
||||
|
||||
maxScroll = Math.max(maxScroll, element.y - maxScroll);
|
||||
return super.dimensions(width, height);
|
||||
}
|
||||
|
||||
int calculateScrollBarHeight() {
|
||||
|
||||
@@ -5,6 +5,7 @@ import org.saturnclient.saturnclient.config.ThemeManager;
|
||||
import org.saturnclient.ui2.Element;
|
||||
import org.saturnclient.ui2.ElementContext;
|
||||
import org.saturnclient.ui2.RenderScope;
|
||||
import org.saturnclient.ui2.resources.Fonts;
|
||||
|
||||
public class Text extends Element {
|
||||
private static ThemeManager theme = new ThemeManager("Text");
|
||||
@@ -15,6 +16,8 @@ public class Text extends Element {
|
||||
|
||||
public Text(String text) {
|
||||
this.text = text;
|
||||
width = Fonts.getWidth(text, font.value);
|
||||
height = Fonts.getHeight();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -17,6 +17,8 @@ public class Textures {
|
||||
"textures/gui/components/toggle_indicator.png");
|
||||
public static final Identifier LEFT = Identifier.of("saturnclient", "textures/gui/components/left.png");
|
||||
public static final Identifier RIGHT = Identifier.of("saturnclient", "textures/gui/components/right.png");
|
||||
public static final Identifier STORE = Identifier.of("saturnclient", "textures/gui/components/store.png");
|
||||
public static final Identifier COINS = Identifier.of("saturnclient", "textures/gui/components/coins.png");
|
||||
|
||||
public static final Identifier LOGO = Identifier.of("saturnclient", "textures/logo/logo.png");
|
||||
public static final Identifier REALISTIC_LOGO = Identifier.of("saturnclient", "textures/logo/realistic.png");
|
||||
|
||||
@@ -30,7 +30,7 @@ public class CloakMenu extends SaturnScreen {
|
||||
if (player != null) {
|
||||
for (String cloak : Cloaks.availableCloaks) {
|
||||
scroll.draw(new CosmeticPreview(cloak == player.cloak, Textures.getCloakPreview(cloak), () -> {
|
||||
Cloaks.setCloak(Auth.uuid, cloak);
|
||||
Cloaks.setCloak(cloak);
|
||||
}).position((50 + g) * col, (111 + g) * row));
|
||||
|
||||
if (col == 5) {
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
package org.saturnclient.ui2.screens;
|
||||
|
||||
import org.saturnclient.saturnclient.auth.Auth;
|
||||
import org.saturnclient.saturnclient.auth.SaturnPlayer;
|
||||
import org.saturnclient.saturnclient.cosmetics.cloaks.Cloaks;
|
||||
import org.saturnclient.ui2.SaturnScreen;
|
||||
import org.saturnclient.ui2.components.CosmeticPreview;
|
||||
import org.saturnclient.ui2.components.Sidebar;
|
||||
import org.saturnclient.ui2.elements.ImageTexture;
|
||||
import org.saturnclient.ui2.elements.Scroll;
|
||||
import org.saturnclient.ui2.elements.Text;
|
||||
import org.saturnclient.ui2.resources.Fonts;
|
||||
import org.saturnclient.ui2.resources.Textures;
|
||||
|
||||
public class Store extends SaturnScreen {
|
||||
public Store() {
|
||||
super("Store");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void ui() {
|
||||
int p = 10;
|
||||
int gx = 10;
|
||||
int gy = 20;
|
||||
|
||||
Scroll scroll = new Scroll(p);
|
||||
|
||||
int row = 0;
|
||||
int col = 0;
|
||||
|
||||
SaturnPlayer player = Auth.players.get(Auth.uuid);
|
||||
|
||||
if (player != null) {
|
||||
for (String cloak : Cloaks.ALL_CLOAKS) {
|
||||
if (!Cloaks.availableCloaks.contains(cloak)) {
|
||||
int x = (50 + gx) * col;
|
||||
int y = (111 + gy) * row;
|
||||
scroll.draw(new CosmeticPreview(cloak == player.cloak, Textures.getCloakPreview(cloak), () -> {
|
||||
Auth.buyCloak(cloak);
|
||||
// This is to refresh the screen to remove the cloak because it's in our inventory
|
||||
resize(client, width, height);
|
||||
}).position(x, y));
|
||||
|
||||
String t = "100";
|
||||
|
||||
scroll.draw(new Text(t).position(x + Fonts.centerX(50, t, Text.font.value), y + 113).scale(0.5f));
|
||||
|
||||
scroll.draw(new ImageTexture(Textures.COINS).dimensions(16, 16).position(x + Fonts.getWidth(t, Text.font.value), y + 112).scale(0.5f));
|
||||
|
||||
if (col == 8) {
|
||||
col = 0;
|
||||
row++;
|
||||
} else {
|
||||
col++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int scrollWidth = 480 + 40 + (gx * 2) + (p * 2);
|
||||
|
||||
draw(scroll.dimensions(scrollWidth, 350).centerOffset(width, height, 15, 0));
|
||||
|
||||
draw(new Sidebar(5, this::close).centerOffset(width, height, -((scrollWidth - 30) / 2 + 20), 0));
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 1.6 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 958 B |
Reference in New Issue
Block a user