2022-12-31 02:12:57 +01:00
|
|
|
#include "Constants.h"
|
2020-01-01 21:29:24 +01:00
|
|
|
#include "Enums.h"
|
2020-07-19 21:05:41 +02:00
|
|
|
#include "Game.h"
|
|
|
|
#include "Graphics.h"
|
2022-12-31 02:12:57 +01:00
|
|
|
#include "Localization.h"
|
2020-12-21 00:19:22 +01:00
|
|
|
#include "KeyPoll.h"
|
2020-07-19 21:05:41 +02:00
|
|
|
#include "UtilityClass.h"
|
2022-12-31 02:12:57 +01:00
|
|
|
#include "VFormat.h"
|
2020-01-01 21:29:24 +01:00
|
|
|
|
2021-01-10 18:14:37 +01:00
|
|
|
static int pre_fakepercent=0, pre_transition=30;
|
|
|
|
static bool pre_startgame=false;
|
|
|
|
static int pre_darkcol=0, pre_lightcol=0, pre_curcol=0, pre_coltimer=0, pre_offset=0;
|
2020-01-01 21:29:24 +01:00
|
|
|
|
2021-01-10 18:14:37 +01:00
|
|
|
static int pre_frontrectx=30, pre_frontrecty=20, pre_frontrectw=260, pre_frontrecth=200;
|
|
|
|
static int pre_temprectx=0, pre_temprecty=0, pre_temprectw=320, pre_temprecth=240;
|
2020-01-01 21:29:24 +01:00
|
|
|
|
Explicitly declare void for all void parameter functions (#628)
Apparently in C, if you have `void test();`, it's completely okay to do
`test(2);`. The function will take in the argument, but just discard it
and throw it away. It's like a trash can, and a rude one at that. If you
declare it like `void test(void);`, this is prevented.
This is not a problem in C++ - doing `void test();` and `test(2);` is
guaranteed to result in a compile error (this also means that right now,
at least in all `.cpp` files, nobody is ever calling a void parameter
function with arguments and having their arguments be thrown away).
However, we may not be using C++ in the future, so I just want to lay
down the precedent that if a function takes in no arguments, you must
explicitly declare it as such.
I would've added `-Wstrict-prototypes`, but it produces an annoying
warning message saying it doesn't work in C++ mode if you're compiling
in C++ mode. So it can be added later.
2021-02-25 23:23:59 +01:00
|
|
|
void preloaderinput(void)
|
2020-12-21 00:19:22 +01:00
|
|
|
{
|
|
|
|
game.press_action = false;
|
|
|
|
|
|
|
|
if (key.isDown(KEYBOARD_z) || key.isDown(KEYBOARD_SPACE) || key.isDown(KEYBOARD_v) || key.isDown(game.controllerButton_flip)) {
|
|
|
|
game.press_action = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (game.press_action) {
|
|
|
|
//Skip to TITLEMODE immediately
|
|
|
|
game.gamestate = TITLEMODE;
|
|
|
|
game.jumpheld = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
Explicitly declare void for all void parameter functions (#628)
Apparently in C, if you have `void test();`, it's completely okay to do
`test(2);`. The function will take in the argument, but just discard it
and throw it away. It's like a trash can, and a rude one at that. If you
declare it like `void test(void);`, this is prevented.
This is not a problem in C++ - doing `void test();` and `test(2);` is
guaranteed to result in a compile error (this also means that right now,
at least in all `.cpp` files, nobody is ever calling a void parameter
function with arguments and having their arguments be thrown away).
However, we may not be using C++ in the future, so I just want to lay
down the precedent that if a function takes in no arguments, you must
explicitly declare it as such.
I would've added `-Wstrict-prototypes`, but it produces an annoying
warning message saying it doesn't work in C++ mode if you're compiling
in C++ mode. So it can be added later.
2021-02-25 23:23:59 +01:00
|
|
|
void preloaderrenderfixed(void)
|
2020-01-01 21:29:24 +01:00
|
|
|
{
|
|
|
|
if (pre_transition < 30) pre_transition--;
|
|
|
|
if(pre_transition>=30){
|
|
|
|
pre_fakepercent++;
|
|
|
|
if (pre_fakepercent >= 100) {
|
|
|
|
pre_fakepercent = 100;
|
|
|
|
pre_startgame = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
pre_offset = (pre_offset + 4 + int(fRandom() * 5.0f))%32;
|
|
|
|
pre_coltimer--;
|
|
|
|
if (pre_coltimer <= 0) {
|
|
|
|
pre_curcol = (pre_curcol + int(fRandom() * 5.0f)) % 6;
|
|
|
|
pre_coltimer = 8;
|
|
|
|
}
|
2020-05-04 19:06:07 +02:00
|
|
|
}
|
2020-11-08 00:47:49 +01:00
|
|
|
|
|
|
|
if (pre_transition <= -10) {
|
|
|
|
game.gamestate = TITLEMODE;
|
|
|
|
}
|
2020-05-04 19:06:07 +02:00
|
|
|
}
|
|
|
|
|
Explicitly declare void for all void parameter functions (#628)
Apparently in C, if you have `void test();`, it's completely okay to do
`test(2);`. The function will take in the argument, but just discard it
and throw it away. It's like a trash can, and a rude one at that. If you
declare it like `void test(void);`, this is prevented.
This is not a problem in C++ - doing `void test();` and `test(2);` is
guaranteed to result in a compile error (this also means that right now,
at least in all `.cpp` files, nobody is ever calling a void parameter
function with arguments and having their arguments be thrown away).
However, we may not be using C++ in the future, so I just want to lay
down the precedent that if a function takes in no arguments, you must
explicitly declare it as such.
I would've added `-Wstrict-prototypes`, but it produces an annoying
warning message saying it doesn't work in C++ mode if you're compiling
in C++ mode. So it can be added later.
2021-02-25 23:23:59 +01:00
|
|
|
void preloaderrender(void)
|
2020-05-04 19:06:07 +02:00
|
|
|
{
|
2022-12-31 02:12:57 +01:00
|
|
|
bool print_percentage = false;
|
|
|
|
|
2020-05-04 19:06:07 +02:00
|
|
|
if(pre_transition>=30){
|
2020-01-01 21:29:24 +01:00
|
|
|
switch(pre_curcol) {
|
2020-04-02 23:22:45 +02:00
|
|
|
case 0:
|
2021-09-11 11:15:20 +02:00
|
|
|
pre_lightcol = graphics.getRGB(0xBF,0x59,0x6F);
|
|
|
|
pre_darkcol = graphics.getRGB(0x88,0x3E,0x53);
|
2020-04-02 23:22:45 +02:00
|
|
|
break;
|
|
|
|
case 1:
|
2021-09-11 11:15:20 +02:00
|
|
|
pre_lightcol = graphics.getRGB(0x6C,0xBC,0x5C);
|
|
|
|
pre_darkcol = graphics.getRGB(0x50,0x86,0x40);
|
2020-04-02 23:22:45 +02:00
|
|
|
break;
|
|
|
|
case 2:
|
2021-09-11 11:15:20 +02:00
|
|
|
pre_lightcol = graphics.getRGB(0x5D,0x57,0xAA);
|
|
|
|
pre_darkcol = graphics.getRGB(0x2F,0x2F,0x6C);
|
2020-04-02 23:22:45 +02:00
|
|
|
break;
|
|
|
|
case 3:
|
2021-09-11 11:15:20 +02:00
|
|
|
pre_lightcol = graphics.getRGB(0xB7,0xBA,0x5E);
|
|
|
|
pre_darkcol = graphics.getRGB(0x84,0x83,0x42);
|
2020-04-02 23:22:45 +02:00
|
|
|
break;
|
|
|
|
case 4:
|
2021-09-11 11:15:20 +02:00
|
|
|
pre_lightcol = graphics.getRGB(0x57,0x90,0xAA);
|
|
|
|
pre_darkcol = graphics.getRGB(0x2F,0x5B,0x6C);
|
2020-04-02 23:22:45 +02:00
|
|
|
break;
|
|
|
|
case 5:
|
2021-09-11 11:15:20 +02:00
|
|
|
pre_lightcol = graphics.getRGB(0x90,0x61,0xB1);
|
|
|
|
pre_darkcol = graphics.getRGB(0x58,0x3D,0x71);
|
2020-04-02 23:22:45 +02:00
|
|
|
break;
|
|
|
|
default:
|
2021-09-11 11:15:20 +02:00
|
|
|
pre_lightcol = graphics.getRGB(0x00,0x00,0x00);
|
|
|
|
pre_darkcol = graphics.getRGB(0x08,0x00,0x00);
|
2020-04-02 23:22:45 +02:00
|
|
|
break;
|
2020-01-01 21:29:24 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
for (int i = 0; i < 18; i++) {
|
|
|
|
pre_temprecty = (i * 16)- pre_offset;
|
2020-04-02 23:20:52 +02:00
|
|
|
if (i % 2 == 0)
|
2020-04-02 23:22:45 +02:00
|
|
|
{
|
2020-04-02 00:01:08 +02:00
|
|
|
FillRect(graphics.backBuffer, pre_temprectx, pre_temprecty, pre_temprectw,pre_temprecth, pre_lightcol);
|
2020-01-01 21:29:24 +01:00
|
|
|
}
|
2020-04-02 23:22:45 +02:00
|
|
|
else
|
|
|
|
{
|
2020-04-02 00:01:08 +02:00
|
|
|
FillRect(graphics.backBuffer, pre_temprectx, pre_temprecty, pre_temprectw,pre_temprecth, pre_darkcol);
|
2020-01-01 21:29:24 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-08-28 21:59:46 +02:00
|
|
|
FillRect(graphics.backBuffer, pre_frontrectx, pre_frontrecty, pre_frontrectw,pre_frontrecth, graphics.getRGB(0x3E,0x31,0xA2));
|
2020-01-01 21:29:24 +01:00
|
|
|
|
2022-12-31 02:12:57 +01:00
|
|
|
print_percentage = true;
|
2020-01-01 21:29:24 +01:00
|
|
|
|
|
|
|
//Render
|
|
|
|
if (pre_startgame) {
|
|
|
|
pre_transition = 29;
|
|
|
|
}
|
|
|
|
}else if (pre_transition <= -10) {
|
2020-11-08 00:47:49 +01:00
|
|
|
//Switch to TITLEMODE (handled by preloaderrenderfixed)
|
2020-01-01 21:29:24 +01:00
|
|
|
}else if (pre_transition < 5) {
|
2021-02-26 00:37:03 +01:00
|
|
|
ClearSurface(graphics.backBuffer);
|
2020-01-01 21:29:24 +01:00
|
|
|
}else if (pre_transition < 20) {
|
|
|
|
pre_temprecty = 0;
|
|
|
|
pre_temprecth = 240;
|
2021-08-28 21:59:27 +02:00
|
|
|
ClearSurface(graphics.backBuffer);
|
2021-08-28 21:59:46 +02:00
|
|
|
FillRect(graphics.backBuffer, pre_frontrectx, pre_frontrecty, pre_frontrectw,pre_frontrecth, graphics.getRGB(0x3E,0x31,0xA2));
|
2020-01-01 21:29:24 +01:00
|
|
|
|
2022-12-31 02:12:57 +01:00
|
|
|
print_percentage = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (print_percentage) {
|
|
|
|
char buffer[SCREEN_WIDTH_CHARS + 1];
|
|
|
|
vformat_buf(
|
|
|
|
buffer, sizeof(buffer),
|
|
|
|
loc::gettext("LOADING... {percent|digits=2|spaces}%"),
|
|
|
|
"percent:int",
|
|
|
|
pre_fakepercent
|
|
|
|
);
|
|
|
|
|
|
|
|
int percentage_len = graphics.len(buffer);
|
|
|
|
graphics.Print(282-percentage_len, 204, buffer, 124, 112, 218, false);
|
2020-01-01 21:29:24 +01:00
|
|
|
}
|
|
|
|
|
2020-04-02 23:22:45 +02:00
|
|
|
graphics.drawfade();
|
|
|
|
|
2020-04-27 04:29:40 +02:00
|
|
|
graphics.render();
|
2020-01-01 21:29:24 +01:00
|
|
|
}
|