mirror of
https://github.com/neoStudiosLCE/neoLegacy.git
synced 2026-08-20 09:57:09 +00:00
Merge remote-tracking branch 'origin/main' into feat/minigames
This commit is contained in:
commit
67ec8f7fb1
|
|
@ -8,6 +8,15 @@ GuiParticles::GuiParticles(Minecraft *mc)
|
||||||
this->mc = mc;
|
this->mc = mc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GuiParticles::~GuiParticles()
|
||||||
|
{
|
||||||
|
for (GuiParticle *gp : particles)
|
||||||
|
{
|
||||||
|
delete gp;
|
||||||
|
}
|
||||||
|
particles.clear();
|
||||||
|
}
|
||||||
|
|
||||||
void GuiParticles::tick()
|
void GuiParticles::tick()
|
||||||
{
|
{
|
||||||
for (unsigned int i = 0; i < particles.size(); i++)
|
for (unsigned int i = 0; i < particles.size(); i++)
|
||||||
|
|
@ -19,6 +28,7 @@ void GuiParticles::tick()
|
||||||
|
|
||||||
if (gp->removed)
|
if (gp->removed)
|
||||||
{
|
{
|
||||||
|
delete gp;
|
||||||
particles.erase(particles.begin()+i);
|
particles.erase(particles.begin()+i);
|
||||||
i--;
|
i--;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@ private:
|
||||||
|
|
||||||
public:
|
public:
|
||||||
GuiParticles(Minecraft *mc);
|
GuiParticles(Minecraft *mc);
|
||||||
|
~GuiParticles();
|
||||||
void tick();
|
void tick();
|
||||||
void add(GuiParticle *guiParticle);
|
void add(GuiParticle *guiParticle);
|
||||||
void render(float a);
|
void render(float a);
|
||||||
|
|
|
||||||
|
|
@ -526,9 +526,10 @@ LevelStorageSource *Minecraft::getLevelSource()
|
||||||
|
|
||||||
void Minecraft::setScreen(Screen *screen)
|
void Minecraft::setScreen(Screen *screen)
|
||||||
{
|
{
|
||||||
if (this->screen != nullptr)
|
Screen *oldScreen = this->screen;
|
||||||
|
if (oldScreen != nullptr)
|
||||||
{
|
{
|
||||||
this->screen->removed();
|
oldScreen->removed();
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef _WINDOWS64
|
#ifdef _WINDOWS64
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,18 @@ Screen::Screen() // 4J added
|
||||||
clickedButton = nullptr;
|
clickedButton = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Screen::~Screen()
|
||||||
|
{
|
||||||
|
delete particles;
|
||||||
|
particles = nullptr;
|
||||||
|
|
||||||
|
for (Button *button : buttons)
|
||||||
|
{
|
||||||
|
delete button;
|
||||||
|
}
|
||||||
|
buttons.clear();
|
||||||
|
}
|
||||||
|
|
||||||
void Screen::render(int xm, int ym, float a)
|
void Screen::render(int xm, int ym, float a)
|
||||||
{
|
{
|
||||||
for (Button* button : buttons)
|
for (Button* button : buttons)
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,7 @@ public:
|
||||||
GuiParticles *particles;
|
GuiParticles *particles;
|
||||||
|
|
||||||
Screen(); // 4J added
|
Screen(); // 4J added
|
||||||
|
virtual ~Screen();
|
||||||
virtual void render(int xm, int ym, float a);
|
virtual void render(int xm, int ym, float a);
|
||||||
protected:
|
protected:
|
||||||
virtual void keyPressed(wchar_t eventCharacter, int eventKey);
|
virtual void keyPressed(wchar_t eventCharacter, int eventKey);
|
||||||
|
|
|
||||||
|
|
@ -149,47 +149,57 @@ static void CopyWideArgToAnsi(LPCWSTR source, char* dest, size_t destSize)
|
||||||
dest[destSize - 1] = 0;
|
dest[destSize - 1] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------- Persistent options (options.txt next to exe) ----------
|
// ---------- Persistent options (options.dat next to exe) ----------
|
||||||
static void GetOptionsFilePath(char *out, size_t outSize)
|
static void GetOptionsFilePath(char *out, DWORD outSize)
|
||||||
{
|
{
|
||||||
GetModuleFileNameA(nullptr, out, static_cast<DWORD>(outSize));
|
GetModuleFileNameA(nullptr, out, outSize);
|
||||||
char *p = strrchr(out, '\\');
|
char *p = strrchr(out, '\\');
|
||||||
if (p) *(p + 1) = '\0';
|
if (p) *(p + 1) = '\0';
|
||||||
strncat_s(out, outSize, "options.txt", _TRUNCATE);
|
strncat_s(out, outSize, "settings.dat", _TRUNCATE);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void SaveFullscreenOption(bool fullscreen)
|
static void SaveFullscreenOption(bool fullscreen)
|
||||||
{
|
{
|
||||||
char path[MAX_PATH];
|
GAME_SETTINGS settings = {};
|
||||||
GetOptionsFilePath(path, sizeof(path));
|
|
||||||
FILE *f = nullptr;
|
char path[MAX_PATH] = {};
|
||||||
if (fopen_s(&f, path, "w") == 0 && f)
|
GetOptionsFilePath(path, MAX_PATH);
|
||||||
{
|
FILE *f = nullptr;
|
||||||
fprintf(f, "fullscreen=%d\n", fullscreen ? 1 : 0);
|
if (fopen_s(&f, path, "rb") == 0 && f)
|
||||||
fclose(f);
|
{
|
||||||
}
|
fread(&settings, sizeof(GAME_SETTINGS), 1, f);
|
||||||
|
fclose(f);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (fullscreen)
|
||||||
|
settings.uiBitmaskValues |= (1UL << 25);
|
||||||
|
else
|
||||||
|
settings.uiBitmaskValues &= ~(1UL << 25);
|
||||||
|
|
||||||
|
if (fopen_s(&f, path, "wb") == 0 && f)
|
||||||
|
{
|
||||||
|
fwrite(&settings, sizeof(GAME_SETTINGS), 1, f);
|
||||||
|
fclose(f);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool LoadFullscreenOption()
|
static bool LoadFullscreenOption()
|
||||||
{
|
{
|
||||||
char path[MAX_PATH];
|
char path[MAX_PATH] = {};
|
||||||
GetOptionsFilePath(path, sizeof(path));
|
GetOptionsFilePath(path, sizeof(path));
|
||||||
FILE *f = nullptr;
|
|
||||||
if (fopen_s(&f, path, "r") == 0 && f)
|
FILE *f = nullptr;
|
||||||
{
|
if (fopen_s(&f, path, "rb") != 0 || !f)
|
||||||
char line[256];
|
return false;
|
||||||
while (fgets(line, sizeof(line), f))
|
|
||||||
{
|
GAME_SETTINGS current = {};
|
||||||
int val = 0;
|
bool ok = (fread(¤t, sizeof(GAME_SETTINGS), 1, f) == 1);
|
||||||
if (sscanf_s(line, "fullscreen=%d", &val) == 1)
|
fclose(f);
|
||||||
{
|
|
||||||
fclose(f);
|
if (!ok)
|
||||||
return val != 0;
|
return false;
|
||||||
}
|
|
||||||
}
|
return (current.uiBitmaskValues & (1UL << 25)) != 0;
|
||||||
fclose(f);
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
// ------------------------------------------------------------------
|
// ------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
@ -824,7 +834,7 @@ BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
@ -1695,11 +1705,12 @@ int APIENTRY _tWinMain(_In_ HINSTANCE hInstance,
|
||||||
CleanupDevice();
|
CleanupDevice();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Restore fullscreen state from previous session. Route through the
|
// Restore fullscreen state from previous session. Route through the
|
||||||
// deferred exclusive fullscreen path so the main loop applies it on the
|
// deferred exclusive fullscreen path so the main loop applies it on the
|
||||||
// first tick (safer than transitioning during init).
|
// first tick (safer than transitioning during init).
|
||||||
if ((LoadFullscreenOption() && !g_isFullscreen) || launchOptions.fullscreen)
|
|
||||||
|
bool FullScreenEnabled = LoadFullscreenOption();
|
||||||
|
if (FullScreenEnabled && !g_isFullscreen)
|
||||||
{
|
{
|
||||||
g_bPendingExclusiveFullscreen = true;
|
g_bPendingExclusiveFullscreen = true;
|
||||||
g_bPendingExclusiveFullscreenValue = true;
|
g_bPendingExclusiveFullscreenValue = true;
|
||||||
|
|
@ -1764,7 +1775,7 @@ int APIENTRY _tWinMain(_In_ HINSTANCE hInstance,
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
g_bResizeReady = true;
|
g_bResizeReady = true;
|
||||||
|
|
||||||
//app.TemporaryCreateGameStart();
|
//app.TemporaryCreateGameStart();
|
||||||
|
|
||||||
//Sleep(10000);
|
//Sleep(10000);
|
||||||
|
|
|
||||||
|
|
@ -54,10 +54,16 @@ AABB *AABB::newPermanent(double x0, double y0, double z0, double x1, double y1,
|
||||||
|
|
||||||
void AABB::clearPool()
|
void AABB::clearPool()
|
||||||
{
|
{
|
||||||
|
ThreadStorage *tls = static_cast<ThreadStorage *>(TlsGetValue(tlsIdx));
|
||||||
|
if (tls != nullptr)
|
||||||
|
{
|
||||||
|
tls->poolPointer = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void AABB::resetPool()
|
void AABB::resetPool()
|
||||||
{
|
{
|
||||||
|
clearPool();
|
||||||
}
|
}
|
||||||
|
|
||||||
AABB *AABB::newTemp(double x0, double y0, double z0, double x1, double y1, double z1)
|
AABB *AABB::newTemp(double x0, double y0, double z0, double x1, double y1, double z1)
|
||||||
|
|
|
||||||
|
|
@ -49,10 +49,16 @@ Vec3 *Vec3::newPermanent(double x, double y, double z)
|
||||||
|
|
||||||
void Vec3::clearPool()
|
void Vec3::clearPool()
|
||||||
{
|
{
|
||||||
|
ThreadStorage *tls = static_cast<ThreadStorage *>(TlsGetValue(tlsIdx));
|
||||||
|
if (tls != nullptr)
|
||||||
|
{
|
||||||
|
tls->poolPointer = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Vec3::resetPool()
|
void Vec3::resetPool()
|
||||||
{
|
{
|
||||||
|
clearPool();
|
||||||
}
|
}
|
||||||
|
|
||||||
Vec3 *Vec3::newTemp(double x, double y, double z)
|
Vec3 *Vec3::newTemp(double x, double y, double z)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue