mirror of
https://github.com/TerryCavanagh/VVVVVV.git
synced 2024-12-23 01:59:43 +01:00
custom textbox colors
Co-authored-by: Misa Elizabeth Kai <infoteddy@infoteddy.info>
This commit is contained in:
parent
de43005676
commit
3d5ba95b96
4 changed files with 53 additions and 0 deletions
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
#include <SDL_stdinc.h>
|
#include <SDL_stdinc.h>
|
||||||
|
|
||||||
|
#include "CustomLevels.h"
|
||||||
#include "Font.h"
|
#include "Font.h"
|
||||||
|
|
||||||
blockclass::blockclass(void)
|
blockclass::blockclass(void)
|
||||||
|
@ -48,6 +49,15 @@ void blockclass::rectset(const int xi, const int yi, const int wi, const int hi)
|
||||||
|
|
||||||
void blockclass::setblockcolour(const char* col)
|
void blockclass::setblockcolour(const char* col)
|
||||||
{
|
{
|
||||||
|
#ifndef NO_CUSTOM_LEVELS
|
||||||
|
if (cl.customcolours.count(col) != 0)
|
||||||
|
{
|
||||||
|
r = cl.customcolours[col].r;
|
||||||
|
g = cl.customcolours[col].g;
|
||||||
|
b = cl.customcolours[col].b;
|
||||||
|
}
|
||||||
|
else // Turn the if into an else if so we don't run the default colour processing
|
||||||
|
#endif
|
||||||
if (SDL_strcmp(col, "cyan") == 0)
|
if (SDL_strcmp(col, "cyan") == 0)
|
||||||
{
|
{
|
||||||
r = 164;
|
r = 164;
|
||||||
|
|
|
@ -389,6 +389,8 @@ void customlevelclass::reset(void)
|
||||||
script.clearcustom();
|
script.clearcustom();
|
||||||
|
|
||||||
onewaycol_override = false;
|
onewaycol_override = false;
|
||||||
|
|
||||||
|
customcolours.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
const int* customlevelclass::loadlevel( int rxi, int ryi )
|
const int* customlevelclass::loadlevel( int rxi, int ryi )
|
||||||
|
@ -1285,6 +1287,35 @@ next:
|
||||||
script.customscripts.push_back(script_);
|
script.customscripts.push_back(script_);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (SDL_strcmp(pKey, "TextboxColours") == 0)
|
||||||
|
{
|
||||||
|
for (tinyxml2::XMLElement* textColourElement = pElem->FirstChildElement(); textColourElement; textColourElement = textColourElement->NextSiblingElement())
|
||||||
|
{
|
||||||
|
if (SDL_strcmp(textColourElement->Value(), "colour") == 0)
|
||||||
|
{
|
||||||
|
int r = 255;
|
||||||
|
int g = 255;
|
||||||
|
int b = 255;
|
||||||
|
|
||||||
|
textColourElement->QueryIntAttribute("r", &r);
|
||||||
|
textColourElement->QueryIntAttribute("g", &g);
|
||||||
|
textColourElement->QueryIntAttribute("b", &b);
|
||||||
|
|
||||||
|
const char* name = textColourElement->Attribute("name");
|
||||||
|
|
||||||
|
if (name != NULL)
|
||||||
|
{
|
||||||
|
SDL_Colour colour;
|
||||||
|
colour.r = r;
|
||||||
|
colour.g = g;
|
||||||
|
colour.b = b;
|
||||||
|
|
||||||
|
customcolours[name] = colour;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mapwidth < maxwidth)
|
if (mapwidth < maxwidth)
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
#include <SDL.h>
|
#include <SDL.h>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include <map>
|
||||||
|
|
||||||
class CustomEntity
|
class CustomEntity
|
||||||
{
|
{
|
||||||
|
@ -169,6 +170,8 @@ public:
|
||||||
SDL_Color getonewaycol(int rx, int ry);
|
SDL_Color getonewaycol(int rx, int ry);
|
||||||
SDL_Color getonewaycol(void);
|
SDL_Color getonewaycol(void);
|
||||||
bool onewaycol_override;
|
bool onewaycol_override;
|
||||||
|
|
||||||
|
std::map<std::string, SDL_Color> customcolours;
|
||||||
};
|
};
|
||||||
|
|
||||||
std::string translate_title(const std::string& title, bool* is_gettext);
|
std::string translate_title(const std::string& title, bool* is_gettext);
|
||||||
|
|
|
@ -442,6 +442,15 @@ void scriptclass::run(void)
|
||||||
{
|
{
|
||||||
//oh boy
|
//oh boy
|
||||||
//first word is the colour.
|
//first word is the colour.
|
||||||
|
#ifndef NO_CUSTOM_LEVELS
|
||||||
|
if (cl.customcolours.count(words[1]) != 0)
|
||||||
|
{
|
||||||
|
r = cl.customcolours[words[1]].r;
|
||||||
|
g = cl.customcolours[words[1]].g;
|
||||||
|
b = cl.customcolours[words[1]].b;
|
||||||
|
}
|
||||||
|
else // Turn the if into an else if so we don't run the default colour processing
|
||||||
|
#endif
|
||||||
if (words[1] == "cyan")
|
if (words[1] == "cyan")
|
||||||
{
|
{
|
||||||
r = 164;
|
r = 164;
|
||||||
|
|
Loading…
Reference in a new issue