mirror of
https://github.com/celisej567/mcpe.git
synced 2026-09-04 19:36:43 +03:00
* Add optional 3d panorama background
This commit is contained in:
8
.gitignore
vendored
8
.gitignore
vendored
@@ -401,6 +401,14 @@ FodyWeavers.xsd
|
||||
/game/assets/particles.png
|
||||
/game/assets/terrain.png
|
||||
|
||||
# Ignore the panorama textures.
|
||||
/game/assets/gui/background/panorama_0.png
|
||||
/game/assets/gui/background/panorama_1.png
|
||||
/game/assets/gui/background/panorama_2.png
|
||||
/game/assets/gui/background/panorama_3.png
|
||||
/game/assets/gui/background/panorama_4.png
|
||||
/game/assets/gui/background/panorama_5.png
|
||||
|
||||
# Avoid including Minecraft Classic assets from Mojang, for now.
|
||||
/game/assets/patches/*.png
|
||||
/game/assets/patches/classic/*.png
|
||||
|
||||
@@ -134,7 +134,7 @@ static void handle_events()
|
||||
}
|
||||
|
||||
// GUI Scale
|
||||
static void calulate_gui_scale()
|
||||
static void calculate_gui_scale()
|
||||
{
|
||||
int width = Minecraft::width;
|
||||
|
||||
@@ -207,6 +207,8 @@ static EM_BOOL main_loop(double time, void *user_data)
|
||||
}
|
||||
}
|
||||
|
||||
extern bool g_bIsMenuBackgroundAvailable; // client/gui/Screen.cpp
|
||||
|
||||
// Main
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
@@ -235,6 +237,8 @@ int main(int argc, char *argv[])
|
||||
Minecraft::height = std::stoi(argv[2]);
|
||||
#endif
|
||||
|
||||
g_bIsMenuBackgroundAvailable = XPL_ACCESS("assets/gui/background/panorama_0.png", 0) == 0;
|
||||
|
||||
// Create Window
|
||||
window = SDL_CreateWindow("ReMinecraftPE", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, Minecraft::width, Minecraft::height, SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN | SDL_WINDOW_RESIZABLE);
|
||||
if (!window)
|
||||
|
||||
@@ -70,6 +70,8 @@ void UpdateMouse()
|
||||
Mouse::_y = g_MousePosY;
|
||||
}
|
||||
|
||||
extern bool g_bIsMenuBackgroundAvailable;
|
||||
|
||||
LRESULT CALLBACK WndProc(HWND hWnd, UINT iMsg, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
switch (iMsg)
|
||||
@@ -218,6 +220,8 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLin
|
||||
wc.lpszMenuName = NULL;
|
||||
wc.lpszClassName = g_WindowClassName;
|
||||
|
||||
g_bIsMenuBackgroundAvailable = XPL_ACCESS("assets/gui/background/panorama_0.png", 0) == 0;
|
||||
|
||||
RECT wr = { 0,0, g_AppPlatform.getScreenWidth(), g_AppPlatform.getScreenHeight() };
|
||||
AdjustWindowRect(&wr, WS_OVERLAPPEDWINDOW, false);
|
||||
int w = wr.right - wr.left;
|
||||
|
||||
@@ -84,6 +84,8 @@ Minecraft::Minecraft() : m_gui(this)
|
||||
m_bHasQueuedScreen = false;
|
||||
m_pQueuedScreen = nullptr;
|
||||
m_licenseID = -2;
|
||||
m_fLastUpdated = 0;
|
||||
m_fDeltaTime = 0;
|
||||
|
||||
#ifndef ORIGINAL_CODE
|
||||
m_pTurnInput = new MouseTurnInput(this);
|
||||
@@ -665,6 +667,10 @@ void Minecraft::update()
|
||||
#endif
|
||||
|
||||
m_pGameRenderer->render(m_timer.field_18);
|
||||
|
||||
double time = double(getTimeS());
|
||||
m_fDeltaTime = time - m_fLastUpdated;
|
||||
m_fLastUpdated = time;
|
||||
}
|
||||
|
||||
void Minecraft::init()
|
||||
|
||||
@@ -127,5 +127,8 @@ public:
|
||||
Screen* m_pQueuedScreen;
|
||||
int m_licenseID;
|
||||
ItemInstance m_CurrItemInstance;
|
||||
|
||||
// in 0.8. Offset 3368
|
||||
double m_fDeltaTime, m_fLastUpdated;
|
||||
};
|
||||
|
||||
|
||||
@@ -115,6 +115,109 @@ void Screen::charInput(char chr)
|
||||
textInput->charPressed(chr);
|
||||
}
|
||||
|
||||
static const char* g_panoramaList[] =
|
||||
{
|
||||
"gui/background/panorama_0.png",
|
||||
"gui/background/panorama_1.png",
|
||||
"gui/background/panorama_2.png",
|
||||
"gui/background/panorama_3.png",
|
||||
"gui/background/panorama_4.png",
|
||||
"gui/background/panorama_5.png",
|
||||
};
|
||||
|
||||
static float g_panoramaAngle = 0.0f;
|
||||
bool g_bIsMenuBackgroundAvailable = false;
|
||||
|
||||
void Screen::renderMenuBackground(float f)
|
||||
{
|
||||
if (!g_bIsMenuBackgroundAvailable)
|
||||
{
|
||||
renderDirtBackground(0);
|
||||
return;
|
||||
}
|
||||
|
||||
g_panoramaAngle += float(30.0 * m_pMinecraft->m_fDeltaTime);
|
||||
|
||||
// not in 0.8
|
||||
glDisable(GL_BLEND);
|
||||
glDisable(GL_CULL_FACE);
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glPushMatrix();
|
||||
glLoadIdentity();
|
||||
gluPerspective(120.0f, 1.0f, 0.05f, 10.0f);
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glPushMatrix();
|
||||
glLoadIdentity();
|
||||
glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
glRotatef(180.0f, 1.0f, 0.0f, 0.0f);
|
||||
glRotatef(Mth::sin((f + g_panoramaAngle) / 400.0f) * 25.0f + 20.0f, 1.0f, 0.0f, 0.0f);
|
||||
glRotatef(-0.1f * (f + g_panoramaAngle), 0.0f, 1.0f, 0.0f);
|
||||
|
||||
for (int i = 0; i < 6; i++)
|
||||
{
|
||||
glPushMatrix();
|
||||
|
||||
float xm = 0.0f, ym = 0.0f, ang = 0.0f;
|
||||
switch (i)
|
||||
{
|
||||
case 1:
|
||||
ang = 90.0f;
|
||||
xm = 0.0f;
|
||||
ym = 1.0f;
|
||||
break;
|
||||
case 2:
|
||||
ang = 180.0f;
|
||||
xm = 0.0f;
|
||||
ym = 1.0f;
|
||||
break;
|
||||
case 3:
|
||||
ang = -90.0f;
|
||||
xm = 0.0f;
|
||||
ym = 1.0f;
|
||||
break;
|
||||
case 4:
|
||||
ang = 90.0f;
|
||||
ym = 0.0f;
|
||||
xm = 1.0f;
|
||||
break;
|
||||
case 5:
|
||||
ang = -90.0f;
|
||||
ym = 0.0f;
|
||||
xm = 1.0f;
|
||||
break;
|
||||
}
|
||||
|
||||
glRotatef(ang, xm, ym, 0.0f);
|
||||
|
||||
m_pMinecraft->m_pTextures->setSmoothing(true);
|
||||
m_pMinecraft->m_pTextures->setClampToEdge(true);
|
||||
m_pMinecraft->m_pTextures->loadAndBindTexture(std::string(g_panoramaList[i]));
|
||||
m_pMinecraft->m_pTextures->setSmoothing(false);
|
||||
m_pMinecraft->m_pTextures->setClampToEdge(false);
|
||||
|
||||
Tesselator& t = Tesselator::instance;
|
||||
t.begin();
|
||||
t.vertexUV(-1.0f, -1.0f, 1.0f, 0.0f, 0.0f);
|
||||
t.vertexUV(+1.0f, -1.0f, 1.0f, 1.0f, 0.0f);
|
||||
t.vertexUV(+1.0f, +1.0f, 1.0f, 1.0f, 1.0f);
|
||||
t.vertexUV(-1.0f, +1.0f, 1.0f, 0.0f, 1.0f);
|
||||
t.draw();
|
||||
|
||||
glPopMatrix();
|
||||
}
|
||||
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glPopMatrix();
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glPopMatrix();
|
||||
glEnable(GL_BLEND);
|
||||
glEnable(GL_CULL_FACE);
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
|
||||
fillGradient(0, 0, m_width, m_height, 0x89000000, 0x89FFFFFF);
|
||||
}
|
||||
|
||||
void Screen::mouseClicked(int xPos, int yPos, int d) // d = clicked?
|
||||
{
|
||||
if (!d) return;
|
||||
@@ -167,6 +270,7 @@ void Screen::render(int xPos, int yPos, float unused)
|
||||
|
||||
void Screen::tick()
|
||||
{
|
||||
g_panoramaAngle++;
|
||||
}
|
||||
|
||||
void Screen::removed()
|
||||
@@ -255,10 +359,10 @@ void Screen::renderDirtBackground(int unk)
|
||||
Tesselator& t = Tesselator::instance;
|
||||
t.begin();
|
||||
t.color(0x404040);
|
||||
t.vertexUV(0.0f, float(m_height), 0, 0, float(unk) + float(m_height) / 32.0f);
|
||||
t.vertexUV(float(m_width), float(m_height), 0, float(unk) + float(m_width) / 32.0f, float(unk) + float(m_height) / 32.0f);
|
||||
t.vertexUV(float(m_width), 0, 0, float(unk) + float(m_width) / 32.0f, 0);
|
||||
t.vertexUV(0.0f, 0, 0, 0, 0);
|
||||
t.vertexUV(0.0f, float(m_height), 0, 0, float(unk) + float(m_height) / 32.0f);
|
||||
t.vertexUV(float(m_width), float(m_height), 0, float(m_width) / 32.0f, float(unk) + float(m_height) / 32.0f);
|
||||
t.vertexUV(float(m_width), 0, 0, float(m_width) / 32.0f, float(unk) + 0.0f);
|
||||
t.vertexUV(0.0f, 0, 0, 0, float(unk) + 0.0f);
|
||||
t.draw();
|
||||
}
|
||||
|
||||
|
||||
@@ -46,6 +46,9 @@ public:
|
||||
virtual void keyPressed(int);
|
||||
virtual void charInput(char);
|
||||
|
||||
// ported from 0.8
|
||||
virtual void renderMenuBackground(float f);
|
||||
|
||||
public:
|
||||
int m_width;
|
||||
int m_height;
|
||||
|
||||
@@ -140,7 +140,10 @@ void OptionsScreen::init()
|
||||
|
||||
void OptionsScreen::render(int a, int b, float c)
|
||||
{
|
||||
renderBackground();
|
||||
if (!m_pMinecraft->isLevelGenerated())
|
||||
renderMenuBackground(c);
|
||||
|
||||
fillGradient(0, 0, m_width, m_height, 0xC0101010, 0xD0101010);
|
||||
|
||||
if (m_pMinecraft->m_pPlatform->getUserInputStatus() >= 0)
|
||||
{
|
||||
|
||||
@@ -455,7 +455,8 @@ bool StartMenuScreen::isInGameScreen()
|
||||
|
||||
void StartMenuScreen::render(int a, int b, float c)
|
||||
{
|
||||
renderBackground();
|
||||
//renderBackground();
|
||||
renderMenuBackground(c);
|
||||
|
||||
Textures* tx = m_pMinecraft->m_pTextures;
|
||||
|
||||
@@ -521,6 +522,7 @@ void StartMenuScreen::render(int a, int b, float c)
|
||||
|
||||
void StartMenuScreen::tick()
|
||||
{
|
||||
Screen::tick();
|
||||
_updateLicense();
|
||||
}
|
||||
|
||||
|
||||
@@ -419,9 +419,25 @@ void ServerSideNetworkHandler::commandTime(OnlinePlayer* player, const std::vect
|
||||
if (!m_pLevel)
|
||||
return;
|
||||
|
||||
if (!parms.empty())
|
||||
{
|
||||
int t = 0;
|
||||
if (!sscanf(parms[0].c_str(), "%d", &t))
|
||||
{
|
||||
sendMessage(player, "Usage: /time [new time value]");
|
||||
return;
|
||||
}
|
||||
|
||||
m_pLevel->setTime(t);
|
||||
sendMessage(player, "Time has been set to " + parms[0]);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
std::stringstream ss;
|
||||
ss << "In-game time: ";
|
||||
ss << m_pLevel->getTime();
|
||||
ss << ". Day " << m_pLevel->getTime() / 24000;
|
||||
sendMessage(player, ss.str());
|
||||
}
|
||||
|
||||
|
||||
@@ -42,6 +42,18 @@ public:
|
||||
void addDynamicTexture(DynamicTexture* pTexture);
|
||||
Texture* getTemporaryTextureData(GLuint id);
|
||||
|
||||
// set smoothing for next texture to be loaded
|
||||
void setSmoothing(bool b)
|
||||
{
|
||||
field_39 = b;
|
||||
}
|
||||
|
||||
// set smoothing for next texture to be loaded
|
||||
void setClampToEdge(bool b)
|
||||
{
|
||||
field_38 = b;
|
||||
}
|
||||
|
||||
Textures(Options*, AppPlatform*);
|
||||
~Textures();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user