mirror of
https://github.com/4jcraft/4jcraft.git
synced 2026-04-24 11:43:36 +00:00
# Conflicts: # Minecraft.Client/Network/PlayerChunkMap.cpp # Minecraft.Client/Network/PlayerList.cpp # Minecraft.Client/Network/ServerChunkCache.cpp # Minecraft.Client/Platform/Common/Consoles_App.cpp # Minecraft.Client/Platform/Common/DLC/DLCManager.cpp # Minecraft.Client/Platform/Common/GameRules/LevelGenerationOptions.cpp # Minecraft.Client/Platform/Common/GameRules/LevelRuleset.cpp # Minecraft.Client/Platform/Common/Tutorial/Tutorial.cpp # Minecraft.Client/Platform/Common/Tutorial/TutorialTask.cpp # Minecraft.Client/Platform/Common/UI/IUIScene_CreativeMenu.cpp # Minecraft.Client/Platform/Common/UI/UIComponent_Panorama.cpp # Minecraft.Client/Platform/Common/UI/UIController.cpp # Minecraft.Client/Platform/Common/UI/UIController.h # Minecraft.Client/Platform/Extrax64Stubs.cpp # Minecraft.Client/Platform/Windows64/4JLibs/inc/4J_Input.h # Minecraft.Client/Platform/Windows64/4JLibs/inc/4J_Storage.h # Minecraft.Client/Player/EntityTracker.cpp # Minecraft.Client/Player/ServerPlayer.cpp # Minecraft.Client/Rendering/EntityRenderers/PlayerRenderer.cpp # Minecraft.Client/Textures/Packs/DLCTexturePack.cpp # Minecraft.Client/Textures/Stitching/StitchedTexture.cpp # Minecraft.Client/Textures/Stitching/TextureMap.cpp # Minecraft.Client/Textures/Textures.cpp # Minecraft.World/Blocks/NotGateTile.cpp # Minecraft.World/Blocks/PressurePlateTile.cpp # Minecraft.World/Blocks/TileEntities/PotionBrewing.cpp # Minecraft.World/Enchantments/EnchantmentHelper.cpp # Minecraft.World/Entities/HangingEntity.cpp # Minecraft.World/Entities/LeashFenceKnotEntity.cpp # Minecraft.World/Entities/LivingEntity.cpp # Minecraft.World/Entities/Mobs/Boat.cpp # Minecraft.World/Entities/Mobs/Minecart.cpp # Minecraft.World/Entities/Mobs/Witch.cpp # Minecraft.World/Entities/SyncedEntityData.cpp # Minecraft.World/Items/LeashItem.cpp # Minecraft.World/Items/PotionItem.cpp # Minecraft.World/Level/BaseMobSpawner.cpp # Minecraft.World/Level/CustomLevelSource.cpp # Minecraft.World/Level/Level.cpp # Minecraft.World/Level/Storage/DirectoryLevelStorage.cpp # Minecraft.World/Level/Storage/McRegionLevelStorage.cpp # Minecraft.World/Level/Storage/RegionFileCache.cpp # Minecraft.World/Player/Player.cpp # Minecraft.World/WorldGen/Biomes/BiomeCache.cpp # Minecraft.World/WorldGen/Features/RandomScatteredLargeFeature.cpp # Minecraft.World/WorldGen/Layers/BiomeOverrideLayer.cpp
208 lines
6 KiB
C++
208 lines
6 KiB
C++
#include "../Platform/stdafx.h"
|
|
#include "Screen.h"
|
|
#include "Button.h"
|
|
#include "../Rendering/Particles/GuiParticles.h"
|
|
#include "../Rendering/Tesselator.h"
|
|
#include "../Textures/Textures.h"
|
|
#include "../../Minecraft.World/Util/SoundTypes.h"
|
|
|
|
Screen::Screen() // 4J added
|
|
{
|
|
minecraft = nullptr;
|
|
width = 0;
|
|
height = 0;
|
|
passEvents = false;
|
|
font = nullptr;
|
|
particles = nullptr;
|
|
clickedButton = nullptr;
|
|
}
|
|
|
|
void Screen::render(int xm, int ym, float a) {
|
|
auto itEnd = buttons.end();
|
|
for (auto it = buttons.begin(); it != itEnd; it++) {
|
|
Button* button = *it; // buttons[i];
|
|
button->render(minecraft, xm, ym);
|
|
}
|
|
}
|
|
|
|
void Screen::keyPressed(wchar_t eventCharacter, int eventKey) {
|
|
if (eventKey == Keyboard::KEY_ESCAPE) {
|
|
minecraft->setScreen(nullptr);
|
|
// minecraft->grabMouse(); // 4J - removed
|
|
// 4jcraft: moved here from PauseScreen to ensure that serverside
|
|
// unpausing is done in all scenarios
|
|
if (g_NetworkManager.IsLocalGame() &&
|
|
g_NetworkManager.GetPlayerCount() == 1)
|
|
app.SetXuiServerAction(ProfileManager.GetPrimaryPad(),
|
|
eXuiServerAction_PauseServer, (void*)FALSE);
|
|
}
|
|
}
|
|
|
|
std::wstring Screen::getClipboard() {
|
|
// 4J - removed
|
|
return std::wstring();
|
|
}
|
|
|
|
void Screen::setClipboard(const std::wstring& str) {
|
|
// 4J - removed
|
|
}
|
|
|
|
void Screen::mouseClicked(int x, int y, int buttonNum) {
|
|
if (buttonNum == 0) {
|
|
auto itEnd = buttons.end();
|
|
for (auto it = buttons.begin(); it != itEnd; it++) {
|
|
Button* button = *it; // buttons[i];
|
|
if (button->clicked(minecraft, x, y)) {
|
|
clickedButton = button;
|
|
minecraft->soundEngine->playUI(eSoundType_RANDOM_CLICK, 1, 1);
|
|
buttonClicked(button);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
void Screen::mouseReleased(int x, int y, int buttonNum) {
|
|
if (clickedButton != nullptr && buttonNum == 0) {
|
|
clickedButton->released(x, y);
|
|
clickedButton = nullptr;
|
|
}
|
|
}
|
|
|
|
void Screen::buttonClicked(Button* button) {}
|
|
|
|
void Screen::init(Minecraft* minecraft, int width, int height) {
|
|
particles = new GuiParticles(minecraft);
|
|
this->minecraft = minecraft;
|
|
this->font = minecraft->font;
|
|
this->width = width;
|
|
this->height = height;
|
|
buttons.clear();
|
|
init();
|
|
}
|
|
|
|
void Screen::setSize(int width, int height) {
|
|
this->width = width;
|
|
this->height = 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();
|
|
}
|
|
|
|
while (Keyboard.next()) {
|
|
keyboardEvent();
|
|
}
|
|
*/
|
|
#endif
|
|
}
|
|
|
|
void Screen::mouseEvent() {
|
|
/* 4J - TODO
|
|
if (Mouse.getEventButtonState()) {
|
|
int xm = Mouse.getEventX() * width / minecraft.width;
|
|
int ym = height - Mouse.getEventY() * height / minecraft.height - 1;
|
|
mouseClicked(xm, ym, Mouse.getEventButton());
|
|
} else {
|
|
int xm = Mouse.getEventX() * width / minecraft.width;
|
|
int ym = height - Mouse.getEventY() * height / minecraft.height - 1;
|
|
mouseReleased(xm, ym, Mouse.getEventButton());
|
|
}
|
|
*/
|
|
}
|
|
|
|
void Screen::keyboardEvent() {
|
|
/* 4J - TODO
|
|
if (Keyboard.getEventKeyState()) {
|
|
if (Keyboard.getEventKey() == Keyboard.KEY_F11) {
|
|
minecraft.toggleFullScreen();
|
|
return;
|
|
}
|
|
keyPressed(Keyboard.getEventCharacter(), Keyboard.getEventKey());
|
|
}
|
|
*/
|
|
}
|
|
|
|
void Screen::tick() {}
|
|
|
|
void Screen::removed() {}
|
|
|
|
void Screen::renderBackground() { renderBackground(0); }
|
|
|
|
void Screen::renderBackground(int vo) {
|
|
if (minecraft->level != nullptr) {
|
|
fillGradient(0, 0, width, height, 0xc0101010, 0xd0101010);
|
|
} else {
|
|
renderDirtBackground(vo);
|
|
}
|
|
}
|
|
|
|
void Screen::renderDirtBackground(int vo) {
|
|
#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; }
|
|
|
|
void Screen::confirmResult(bool result, int id) {}
|
|
|
|
void Screen::tabPressed() {}
|