From 0d1387ad8f3f60476af86da754261321b11730e0 Mon Sep 17 00:00:00 2001 From: deepfriedwaffles Date: Tue, 17 Mar 2026 02:31:41 -0400 Subject: [PATCH] added needed missing files --- src/client/KeyMapping.h | 21 ++++ src/client/gui/components/OptionsPane.cpp | 63 +++++++++++ src/client/gui/components/OptionsPane.h | 30 +++++ src/client/gui/components/SmallButton.cpp | 24 ++++ src/client/gui/components/SmallButton.h | 23 ++++ src/client/gui/screens/BuyGameScreen.h | 26 +++++ src/client/gui/screens/InvalidLicenseScreen.h | 107 ++++++++++++++++++ 7 files changed, 294 insertions(+) create mode 100644 src/client/KeyMapping.h create mode 100644 src/client/gui/components/OptionsPane.cpp create mode 100644 src/client/gui/components/OptionsPane.h create mode 100644 src/client/gui/components/SmallButton.cpp create mode 100644 src/client/gui/components/SmallButton.h create mode 100644 src/client/gui/screens/BuyGameScreen.h create mode 100644 src/client/gui/screens/InvalidLicenseScreen.h diff --git a/src/client/KeyMapping.h b/src/client/KeyMapping.h new file mode 100644 index 0000000..06740c8 --- /dev/null +++ b/src/client/KeyMapping.h @@ -0,0 +1,21 @@ +#ifndef NET_MINECRAFT_CLIENT__KeyMapping_H__ +#define NET_MINECRAFT_CLIENT__KeyMapping_H__ + +//package net.minecraft.client; +#include + +class KeyMapping +{ +public: + std::string name; + int key; + + KeyMapping() {} + + KeyMapping(const std::string& name_, int key_) + : name(name_), + key(key_) + {} +}; + +#endif /*NET_MINECRAFT_CLIENT__KeyMapping_H__*/ diff --git a/src/client/gui/components/OptionsPane.cpp b/src/client/gui/components/OptionsPane.cpp new file mode 100644 index 0000000..8cc5d70 --- /dev/null +++ b/src/client/gui/components/OptionsPane.cpp @@ -0,0 +1,63 @@ +#include "OptionsPane.h" +#include "OptionsGroup.h" +#include "OptionsItem.h" +#include "ImageButton.h" +#include "Slider.h" +#include "../../Minecraft.h" + +OptionsPane::OptionsPane() { + +} + +void OptionsPane::setupPositions() { + int currentHeight = y + 1; + for(std::vector::iterator it = children.begin(); it != children.end(); ++it ) { + (*it)->width = width; + (*it)->y = currentHeight; + (*it)->x = x; + currentHeight += (*it)->height + 1; + } + height = currentHeight; + super::setupPositions(); +} + +OptionsGroup& OptionsPane::createOptionsGroup( std::string label ) { + OptionsGroup* newGroup = new OptionsGroup(label); + children.push_back(newGroup); + // create and return a new group index + return *newGroup; +} + +void OptionsPane::createToggle( unsigned int group, std::string label, const Options::Option* option ) { + if(group > children.size()) return; + ImageDef def; + def.setSrc(IntRectangle(160, 206, 39, 20)); + def.name = "gui/touchgui.png"; + def.width = 39 * 0.7f; + def.height = 20 * 0.7f; + OptionButton* element = new OptionButton(option); + element->setImageDef(def, true); + OptionsItem* item = new OptionsItem(label, element); + ((OptionsGroup*)children[group])->addChild(item); + setupPositions(); +} + +void OptionsPane::createProgressSlider( Minecraft* minecraft, unsigned int group, std::string label, const Options::Option* option, float progressMin/*=1.0f*/, float progressMax/*=1.0f */ ) { + if(group > children.size()) return; + Slider* element = new Slider(minecraft, option, progressMin, progressMax); + element->width = 100; + element->height = 20; + OptionsItem* item = new OptionsItem(label, element); + ((OptionsGroup*)children[group])->addChild(item); + setupPositions(); +} + +void OptionsPane::createStepSlider( Minecraft* minecraft, unsigned int group, std::string label, const Options::Option* option, const std::vector& stepVec ) { + if(group > children.size()) return; + Slider* element = new Slider(minecraft, option, stepVec); + element->width = 100; + element->height = 20; + OptionsItem* item = new OptionsItem(label, element); + ((OptionsGroup*)children[group])->addChild(item); + setupPositions(); +} \ No newline at end of file diff --git a/src/client/gui/components/OptionsPane.h b/src/client/gui/components/OptionsPane.h new file mode 100644 index 0000000..5eb9652 --- /dev/null +++ b/src/client/gui/components/OptionsPane.h @@ -0,0 +1,30 @@ +#ifndef ITEMPANE_H__ +#define ITEMPANE_H__ + +#include +#include +#include "GuiElementContainer.h" +#include "../../../world/item/ItemInstance.h" +#include "../../../client/Options.h" +class Font; +class Textures; +class NinePatchLayer; +class ItemPane; +class OptionButton; +class Button; +class OptionsGroup; +class Slider; +class Minecraft; +class OptionsPane: public GuiElementContainer +{ + typedef GuiElementContainer super; +public: + OptionsPane(); + OptionsGroup& createOptionsGroup( std::string label ); + void createToggle( unsigned int group, std::string label, const Options::Option* option ); + void createProgressSlider(Minecraft* minecraft, unsigned int group, std::string label, const Options::Option* option, float progressMin=1.0f, float progressMax=1.0f ); + void createStepSlider(Minecraft* minecraft, unsigned int group, std::string label, const Options::Option* option, const std::vector& stepVec ); + void setupPositions(); +}; + +#endif /*ITEMPANE_H__*/ diff --git a/src/client/gui/components/SmallButton.cpp b/src/client/gui/components/SmallButton.cpp new file mode 100644 index 0000000..e2ebfaa --- /dev/null +++ b/src/client/gui/components/SmallButton.cpp @@ -0,0 +1,24 @@ +#include "SmallButton.h" + +SmallButton::SmallButton( int id, int x, int y, const std::string& msg ) +: super(id, x, y, 150, 20, msg), + option(NULL) +{ +} + +SmallButton::SmallButton( int id, int x, int y, int width, int height, const std::string& msg ) +: super(id, x, y, width, height, msg), + option(NULL) +{ +} + +SmallButton::SmallButton( int id, int x, int y, Options::Option* item, const std::string& msg ) +: super(id, x, y, 150, 20, msg), + option(item) +{ +} + +Options::Option* SmallButton::getOption() +{ + return option; +} diff --git a/src/client/gui/components/SmallButton.h b/src/client/gui/components/SmallButton.h new file mode 100644 index 0000000..05ae378 --- /dev/null +++ b/src/client/gui/components/SmallButton.h @@ -0,0 +1,23 @@ +#ifndef NET_MINECRAFT_CLIENT_GUI_COMPONENTS__SmallButton_H__ +#define NET_MINECRAFT_CLIENT_GUI_COMPONENTS__SmallButton_H__ + +//package net.minecraft.client.gui; + +#include +#include "Button.h" +#include "../../Options.h" + +class SmallButton: public Button +{ + typedef Button super; +public: + SmallButton(int id, int x, int y, const std::string& msg); + SmallButton(int id, int x, int y, int width, int height, const std::string& msg); + SmallButton(int id, int x, int y, Options::Option* item, const std::string& msg); + + Options::Option* getOption(); +private: + Options::Option* option; +}; + +#endif /*NET_MINECRAFT_CLIENT_GUI_COMPONENTS__SmallButton_H__*/ diff --git a/src/client/gui/screens/BuyGameScreen.h b/src/client/gui/screens/BuyGameScreen.h new file mode 100644 index 0000000..228cdba --- /dev/null +++ b/src/client/gui/screens/BuyGameScreen.h @@ -0,0 +1,26 @@ +#ifndef NET_MINECRAFT_CLIENT_GUI_SCREENS__BuyGameScreen_H__ +#define NET_MINECRAFT_CLIENT_GUI_SCREENS__BuyGameScreen_H__ + +#include "../Screen.h" +#include "../components/Button.h" + +class BuyGameScreen: public Screen +{ +public: + BuyGameScreen() {} + virtual ~BuyGameScreen() {} + + void init(); + + void render(int xm, int ym, float a); + + void buttonClicked(Button* button) { + //if (button->id == bQuit.id) + } + +private: + //Button bQuit; + //Button bBuyGame; +}; + +#endif /*NET_MINECRAFT_CLIENT_GUI_SCREENS__BuyGameScreen_H__*/ diff --git a/src/client/gui/screens/InvalidLicenseScreen.h b/src/client/gui/screens/InvalidLicenseScreen.h new file mode 100644 index 0000000..2801521 --- /dev/null +++ b/src/client/gui/screens/InvalidLicenseScreen.h @@ -0,0 +1,107 @@ +#ifndef NET_MINECRAFT_CLIENT_GUI_SCREENS__InvalidLicenseScreen_H__ +#define NET_MINECRAFT_CLIENT_GUI_SCREENS__InvalidLicenseScreen_H__ + +#include "../Screen.h" +#include "../components/Button.h" +#include "../../Minecraft.h" +#include "../../../LicenseCodes.h" + +class InvalidLicenseScreen: public Screen +{ +public: + InvalidLicenseScreen(int id, bool hasBuyButton) + : _id(id), + _hasBuyButton(hasBuyButton), + _baseY(0), + bOk(0), + bBuy(0) + { + } + + virtual ~InvalidLicenseScreen() { + delete bOk; + delete bBuy; + } + + void init() { + if (minecraft->useTouchscreen()) { + bOk = new Touch::TButton(1, "Ok"); + bBuy = new Touch::TButton(2, "Buy"); + } else { + bOk = new Button(1, "Ok"); + bBuy = new Button(2, "Buy"); + } + + if (_hasBuyButton) + bOk->msg = "Quit"; + + if (!LicenseCodes::isOk(_id)) { + char buf[20] = {0}; + sprintf(buf, "%d", _id); + + desc1 = "License verification failed (error "; + desc1 += buf; + desc1 += ")"; + desc2 = "Try again later."; + hint = "You need to be connected to the internet\n"; + hint += "once while you start the game."; + } + + buttons.push_back(bOk); + tabButtons.push_back(bOk); + + if (_hasBuyButton) { + buttons.push_back(bBuy); + tabButtons.push_back(bBuy); + } + } + + void setupPositions() { + _baseY = height/5 + 6; + //if (_hasBuyButton) + _baseY -= 24; + + bOk->width = bBuy->width = 200; + bOk->x = bBuy->x = (width - bOk->width) / 2; + bBuy->y = _baseY + 84; + bOk->y = bBuy->y + bBuy->height + 4; + + if (!_hasBuyButton) + bOk->y -= 24; + } + + void tick() {} + + //void keyPressed(int eventKey) {} + + void render(int xm, int ym, float a) { + renderDirtBackground(0); + drawCenteredString(minecraft->font, desc1, width/2, _baseY, 0xffffff); + drawCenteredString(minecraft->font, desc2, width/2, _baseY + 24, 0xffffff); + + drawCenteredString(minecraft->font, hint, width/2, _baseY + 60, 0xffffff); + + Screen::render(xm, ym, a); + } + + void buttonClicked(Button* button) { + if (button->id == bOk->id) { + minecraft->quit(); + } + if (button->id == bBuy->id) { + minecraft->platform()->buyGame(); + } + }; +private: + int _id; + std::string desc1; + std::string desc2; + std::string hint; + + Button* bOk; + Button* bBuy; + bool _hasBuyButton; + int _baseY; +}; + +#endif /*NET_MINECRAFT_CLIENT_GUI_SCREENS__InvalidLicenseScreen_H__*/