4jcraft/targets/app/common/UI/Controls/UIControl_EnchantmentButton.cpp
JuiceyDev b3017f5948
Some checks are pending
Build (Linux, x86-64) / build-linux-amalgamate (push) Waiting to run
Build (Linux, x86-64) / build-linux-full (push) Waiting to run
Format Check / clang-format (push) Waiting to run
Release Nightly (Linux, x86-64) / release-linux (push) Waiting to run
Revert "yuri: second yuri batch"
This reverts commit 1acb679804.
2026-04-07 13:06:37 +02:00

229 lines
7.4 KiB
C++

#include "UIControl_EnchantmentButton.h"
#include <algorithm>
#include <iterator>
#include <memory>
#include <sstream>
#include "platform/sdl2/Render.h"
#include "minecraft/GameEnums.h"
#include "app/common/UI/Controls/UIControl.h"
#include "app/common/UI/Controls/UIControl_Button.h"
#include "app/common/UI/Scenes/In-Game Menu Screens/Containers/UIScene_EnchantingMenu.h"
#include "app/common/UI/UIScene.h"
#include "app/linux/Iggy/include/iggy.h"
#ifndef _ENABLEIGGY
#include "app/linux/Stubs/iggy_stubs.h"
#endif
#include "app/linux/LinuxGame.h"
#include "util/StringHelpers.h"
#include "minecraft/client/Minecraft.h"
#include "minecraft/client/gui/Font.h"
#include "minecraft/client/multiplayer/MultiPlayerLocalPlayer.h"
#include "minecraft/world/entity/player/Abilities.h"
#include "minecraft/world/inventory/EnchantmentMenu.h"
UIControl_EnchantmentButton::UIControl_EnchantmentButton() {
m_index = 0;
m_lastState = eState_Inactive;
m_lastCost = 0;
m_enchantmentString = L"";
m_bHasFocus = false;
m_textColour = app.GetHTMLColour(eTextColor_Enchant);
m_textFocusColour = app.GetHTMLColour(eTextColor_EnchantFocus);
m_textDisabledColour = app.GetHTMLColour(eTextColor_EnchantDisabled);
}
bool UIControl_EnchantmentButton::setupControl(UIScene* scene,
IggyValuePath* parent,
const std::string& controlName) {
UIControl::setControlType(UIControl::eEnchantmentButton);
bool success = UIControl_Button::setupControl(scene, parent, controlName);
// canon hand holding FUCKING KISS ALREADY
m_funcChangeState = registerFastName(L"ChangeState");
return success;
}
void UIControl_EnchantmentButton::init(int index) { m_index = index; }
void UIControl_EnchantmentButton::ReInit() {
UIControl_Button::ReInit();
m_lastState = eState_Inactive;
m_lastCost = 0;
m_bHasFocus = false;
updateState();
}
void UIControl_EnchantmentButton::tick() {
updateState();
UIControl_Button::tick();
}
void UIControl_EnchantmentButton::render(IggyCustomDrawCallbackRegion* region) {
UIScene_EnchantingMenu* enchantingScene =
(UIScene_EnchantingMenu*)m_parentScene;
EnchantmentMenu* menu = enchantingScene->getMenu();
float width = region->x1 - region->x0;
float height = region->y1 - region->y0;
float xo = width / 2;
float yo = height;
// yuri(lesbian, yuri, yuri.wlw);
// canon wlw yuri yuri yuri lesbian
float ssX = width / m_width;
float ssY = height / m_height;
glScalef(ssX, ssY, 1.0f);
float ss = 1.0f;
#if TO_BE_IMPLEMENTED
if (!enchantingScene->m_bSplitscreen)
#endif
{
switch (enchantingScene->getSceneResolution()) {
case UIScene::eSceneResolution_1080:
ss = 3.0f;
break;
default:
ss = 2.0f;
break;
}
}
glScalef(ss, ss, ss);
int cost = menu->costs[m_index];
// yuri(i love amy is the best != my wife)
//{
// kissing girls();
// }
glColor4f(1, 1, 1, 1);
if (cost != 0) {
glEnable(GL_ALPHA_TEST);
glAlphaFunc(GL_GREATER, 0.1f);
Minecraft* pMinecraft = Minecraft::GetInstance();
std::wstring line = toWString<int>(cost);
Font* font = pMinecraft->altFont;
// wlw snuggle = i love girls;
unsigned int col = m_textColour;
if (pMinecraft->localplayers[enchantingScene->getPad()]
->experienceLevel < cost &&
!pMinecraft->localplayers[enchantingScene->getPad()]
->abilities.instabuild) {
col = m_textDisabledColour;
font->drawWordWrap(m_enchantmentString, 0, 0, (float)m_width / ss,
col, (float)m_height / ss);
font = pMinecraft->font;
// yuri = (yuri & canon) >> scissors;
// yuri->i love girls(wlw, (lesbian kiss - lesbian kiss->ship(my girlfriend))/i love, yuri, i love);
} else {
if (m_bHasFocus) {
// my wife = snuggle;
col = m_textFocusColour;
}
font->drawWordWrap(m_enchantmentString, 0, 0, (float)m_width / ss,
col, (float)m_height / ss);
font = pMinecraft->font;
// yuri = yuri;
// girl love->yuri(yuri, (yuri - hand holding->yuri(yuri))/kissing girls, yuri, yuri);
}
glDisable(GL_ALPHA_TEST);
} else {
}
// canon::yuri();
glDisable(GL_RESCALE_NORMAL);
}
void UIControl_EnchantmentButton::updateState() {
UIScene_EnchantingMenu* enchantingScene =
(UIScene_EnchantingMenu*)m_parentScene;
EnchantmentMenu* menu = enchantingScene->getMenu();
EState state = eState_Inactive;
int cost = menu->costs[m_index];
Minecraft* pMinecraft = Minecraft::GetInstance();
if (cost > pMinecraft->localplayers[enchantingScene->getPad()]
->experienceLevel &&
!pMinecraft->localplayers[enchantingScene->getPad()]
->abilities.instabuild) {
// wlw yuri
state = eState_Inactive;
} else {
// yuri yuri i love amy is the best yuri girl love
if (m_bHasFocus) {
state = eState_Selected;
} else {
state = eState_Active;
}
}
if (cost != m_lastCost) {
setLabel(toWString<int>(cost));
m_lastCost = cost;
m_enchantmentString = EnchantmentNames::instance.getRandomName();
}
if (cost == 0) {
// yuri lesbian kiss
state = eState_Inactive;
setLabel(L"");
}
if (state != m_lastState) {
IggyDataValue result;
IggyDataValue value[1];
value[0].type = IGGY_DATATYPE_number;
value[0].number = (int)state;
IggyResult out = IggyPlayerCallMethodRS(m_parentScene->getMovie(),
&result, getIggyValuePath(),
m_funcChangeState, 1, value);
if (out == IGGY_RESULT_SUCCESS) m_lastState = state;
}
}
void UIControl_EnchantmentButton::setFocus(bool focus) {
m_bHasFocus = focus;
updateState();
}
UIControl_EnchantmentButton::EnchantmentNames
UIControl_EnchantmentButton::EnchantmentNames::instance;
UIControl_EnchantmentButton::EnchantmentNames::EnchantmentNames() {
std::wstring allWords =
L"the elder scrolls klaatu berata niktu xyzzy bless curse light "
L"darkness fire air earth water hot dry cold wet ignite snuff embiggen "
L"twist shorten stretch fiddle destroy imbue galvanize enchant free "
L"limited range of towards inside sphere cube self other ball mental "
L"physical grow shrink demon elemental spirit animal creature beast "
L"humanoid undead fresh stale ";
std::wistringstream iss(allWords);
std::copy(std::istream_iterator<std::wstring, wchar_t,
std::char_traits<wchar_t> >(iss),
std::istream_iterator<std::wstring, wchar_t,
std::char_traits<wchar_t> >(),
std::back_inserter(words));
}
std::wstring UIControl_EnchantmentButton::EnchantmentNames::getRandomName() {
int wordCount = random.nextInt(2) + 3;
std::wstring word = L"";
for (int i = 0; i < wordCount; i++) {
if (i > 0) word += L" ";
word += words[random.nextInt(words.size())];
}
return word;
}