Skip to content

Commit

Permalink
fix: Space Race Manager screen not rendering as it should (#321)
Browse files Browse the repository at this point in the history
* fix: Space Race Manager screen rendering out of order

* fix: Space Race Manager screen animation not respecting framerate

* chore: combine Space Race Manager button renderers

* fix: button renderer

* refactor: convert Space Race Manager buttons to widgets

* refactor: better Space Race Manager menu switching

* feat: team color menu and customize flag button

* feat: Space Race menu translations

* wip: draw flag when confirming after drag+drop

* fix: license header in ConfirmFlagScreen.java

* feat: draw flag in space race menu

* fix: pose stack usage in ConfirmFlagScreen.java

* fix: use the right function in SpaceRaceScreen.java

Co-authored-by: marcus8448 <marcus8448_devtools@outlook.com>

---------

Co-authored-by: marcus8448 <marcus8448_devtools@outlook.com>
  • Loading branch information
JustAPotota and marcus8448 committed May 31, 2024
1 parent 3f46476 commit 350fdd4
Show file tree
Hide file tree
Showing 5 changed files with 328 additions and 241 deletions.
10 changes: 9 additions & 1 deletion src/main/generated/assets/galacticraft/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -594,13 +594,21 @@
"ui.galacticraft.space_race_manager.back": "Back",
"ui.galacticraft.space_race_manager.button": "Space Race",
"ui.galacticraft.space_race_manager.button_2": "Manager",
"ui.galacticraft.space_race_manager.color.blue": "Blue",
"ui.galacticraft.space_race_manager.color.green": "Green",
"ui.galacticraft.space_race_manager.color.red": "Red",
"ui.galacticraft.space_race_manager.coming_soon": "Coming Soon™",
"ui.galacticraft.space_race_manager.customize_flag": "Customize Flag",
"ui.galacticraft.space_race_manager.drap_and_drop_flag": "Drag and drop an image to use as a flag",
"ui.galacticraft.space_race_manager.exit": "Exit",
"ui.galacticraft.space_race_manager.flag.confirm": "Confirm Flag",
"ui.galacticraft.space_race_manager.flag.confirm": "Use this team flag?",
"ui.galacticraft.space_race_manager.flag.confirm.message": "",
"ui.galacticraft.space_race_manager.global_stats": "Global Statistics",
"ui.galacticraft.space_race_manager.remove_players": "Remove Player(s)",
"ui.galacticraft.space_race_manager.server_stats": "Server Statistics",
"ui.galacticraft.space_race_manager.team_color_1": "Change",
"ui.galacticraft.space_race_manager.team_color_2": "Team",
"ui.galacticraft.space_race_manager.team_color_3": "Color",
"ui.galacticraft.status.already_sealed": "Already Sealed",
"ui.galacticraft.status.area_too_large": "Area Too Large",
"ui.galacticraft.status.blocked": "Blocked",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/*
* Copyright (c) 2019-2024 Team Galacticraft
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/

package dev.galacticraft.mod.client.gui.screen.ingame;

import it.unimi.dsi.fastutil.booleans.BooleanConsumer;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.screens.ConfirmScreen;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.Mth;

public class ConfirmFlagScreen extends ConfirmScreen {
protected final ResourceLocation imageLocation;
public ConfirmFlagScreen(BooleanConsumer booleanConsumer, ResourceLocation flagImage, Component component, Component component2) {
super(booleanConsumer, component, component2);
this.imageLocation = flagImage;
}

private int titleTop() {
int i = this.height/2;
return Mth.clamp(i - 20 - this.font.lineHeight, 10, 80);
}

private int flagTop() {
return this.titleTop() + 20;
}

@Override
public void render(GuiGraphics graphics, int mouseX, int mouseY, float delta) {
super.render(graphics, mouseX, mouseY, delta);
graphics.blit(this.imageLocation, this.width/2 - 24, this.flagTop(), 0, 0, 0, 48, 32, 48, 32);
}
}
Loading

0 comments on commit 350fdd4

Please sign in to comment.