mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/4jcraft.git
synced 2026-06-17 04:02:01 +00:00
Merge pull request #155 from 4jcraft/feat/restore-java-gui
feat: restore unused java GUI
This commit is contained in:
@@ -82,6 +82,39 @@ void Screen::setSize(int width, int height) {
|
||||
void Screen::init() {}
|
||||
|
||||
void Screen::updateEvents() {
|
||||
// TODO: update for SDL if we ever get around to that
|
||||
#if (defined(ENABLE_JAVA_GUIS))
|
||||
int fbw, fbh;
|
||||
RenderManager.GetFramebufferSize(fbw, fbh);
|
||||
glViewport(0, 0, fbw, fbh);
|
||||
ScreenSizeCalculator ssc(minecraft->options, minecraft->width,
|
||||
minecraft->height);
|
||||
int screenWidth = ssc.getWidth();
|
||||
int screenHeight = ssc.getHeight();
|
||||
int xMouse = InputManager.GetMouseX() * screenWidth / fbw;
|
||||
int yMouse = InputManager.GetMouseY() * screenHeight / fbh - 1;
|
||||
|
||||
static bool prevLeftState = false;
|
||||
static bool prevRightState = false;
|
||||
|
||||
bool leftState = InputManager.ButtonDown(0, MINECRAFT_ACTION_ACTION);
|
||||
bool rightState = InputManager.ButtonDown(0, MINECRAFT_ACTION_USE);
|
||||
|
||||
if (leftState && !prevLeftState) {
|
||||
mouseClicked(xMouse, yMouse, 0);
|
||||
} else if (!leftState && prevLeftState) {
|
||||
mouseReleased(xMouse, yMouse, 0);
|
||||
}
|
||||
|
||||
if (rightState && !prevRightState) {
|
||||
mouseClicked(xMouse, yMouse, 1);
|
||||
} else if (!rightState && prevRightState) {
|
||||
mouseReleased(xMouse, yMouse, 1);
|
||||
}
|
||||
|
||||
prevLeftState = leftState;
|
||||
prevRightState = rightState;
|
||||
#else
|
||||
/* 4J - TODO
|
||||
while (Mouse.next()) {
|
||||
mouseEvent();
|
||||
@@ -91,6 +124,7 @@ while (Keyboard.next()) {
|
||||
keyboardEvent();
|
||||
}
|
||||
*/
|
||||
#endif
|
||||
}
|
||||
|
||||
void Screen::mouseEvent() {
|
||||
@@ -135,6 +169,30 @@ void Screen::renderBackground(int vo) {
|
||||
|
||||
void Screen::renderDirtBackground(int vo) {
|
||||
// 4J Unused - Iggy Flash UI renders the background on consoles
|
||||
#ifdef ENABLE_JAVA_GUIS
|
||||
glDisable(GL_LIGHTING);
|
||||
glDisable(GL_FOG);
|
||||
Tesselator* t = Tesselator::getInstance();
|
||||
glBindTexture(GL_TEXTURE_2D,
|
||||
minecraft->textures->loadTexture(TN_GUI_BACKGROUND));
|
||||
glColor4f(1, 1, 1, 1);
|
||||
float s = 32;
|
||||
t->begin();
|
||||
t->color(0x404040);
|
||||
t->vertexUV(static_cast<float>(0), static_cast<float>(height),
|
||||
static_cast<float>(0), static_cast<float>(0),
|
||||
static_cast<float>(height / s + vo));
|
||||
t->vertexUV(static_cast<float>(width), static_cast<float>(height),
|
||||
static_cast<float>(0), static_cast<float>(width / s),
|
||||
static_cast<float>(height / s + vo));
|
||||
t->vertexUV(static_cast<float>(width), static_cast<float>(0),
|
||||
static_cast<float>(0), static_cast<float>(width / s),
|
||||
static_cast<float>(0 + vo));
|
||||
t->vertexUV(static_cast<float>(0), static_cast<float>(0),
|
||||
static_cast<float>(0), static_cast<float>(0),
|
||||
static_cast<float>(0 + vo));
|
||||
t->end();
|
||||
#endif
|
||||
}
|
||||
|
||||
bool Screen::isPauseScreen() { return true; }
|
||||
|
||||
Reference in New Issue
Block a user