diff --git a/desktop_version/src/CustomLevels.cpp b/desktop_version/src/CustomLevels.cpp index bd8ac2aa..2e3f84fe 100644 --- a/desktop_version/src/CustomLevels.cpp +++ b/desktop_version/src/CustomLevels.cpp @@ -404,6 +404,8 @@ void customlevelclass::reset(void) script.textbox_colours.clear(); script.add_default_colours(); map.specialroomnames.clear(); + + player_colour = 0; } const int* customlevelclass::loadlevel( int rxi, int ryi ) @@ -1414,6 +1416,11 @@ next: map.specialroomnames.push_back(name); } } + + if (SDL_strcmp(pKey, "PlayerColour") == 0) + { + player_colour = help.Int(pText); + } } if (mapwidth < maxwidth) @@ -1558,6 +1565,20 @@ bool customlevelclass::save(const std::string& _path) } } + if (player_colour != 0) + { + xml::update_tag(msg, "PlayerColour", player_colour); + } + else + { + // Get rid of this one as well, since older levels don't have this property anyways + tinyxml2::XMLElement* element; + while ((element = msg->FirstChildElement("PlayerColour")) != NULL) + { + doc.DeleteNode(element); + } + } + xml::update_tag(data, "mapwidth", mapwidth); xml::update_tag(data, "mapheight", mapheight); diff --git a/desktop_version/src/CustomLevels.h b/desktop_version/src/CustomLevels.h index b728d412..22285182 100644 --- a/desktop_version/src/CustomLevels.h +++ b/desktop_version/src/CustomLevels.h @@ -170,6 +170,8 @@ public: SDL_Color getonewaycol(int rx, int ry); SDL_Color getonewaycol(void); bool onewaycol_override; + + int player_colour; }; bool translate_title(const std::string& title); diff --git a/desktop_version/src/Editor.cpp b/desktop_version/src/Editor.cpp index 2a04509e..fe89d98d 100644 --- a/desktop_version/src/Editor.cpp +++ b/desktop_version/src/Editor.cpp @@ -1048,11 +1048,11 @@ static void draw_entities(void) if (entity->p1 == 0) // Facing right { - graphics.draw_sprite(x - 4, y, 0, graphics.col_crewcyan); + graphics.draw_sprite(x - 4, y, 0, graphics.getcol(cl.player_colour)); } else // Non-zero is facing left { - graphics.draw_sprite(x - 4, y, 3, graphics.col_crewcyan); + graphics.draw_sprite(x - 4, y, 3, graphics.getcol(cl.player_colour)); } graphics.draw_rect(x, y, 16, 24, graphics.getRGB(255, 255, 164)); @@ -1959,6 +1959,8 @@ void editorrenderfixed(void) const RoomProperty* const room = cl.getroomprop(ed.levx, ed.levy); graphics.updatetitlecolours(); + graphics.trinketcolset = false; + game.customcol = cl.getlevelcol(room->tileset, room->tilecol) + 1; ed.entcol = cl.getenemycol(game.customcol); diff --git a/desktop_version/src/Script.cpp b/desktop_version/src/Script.cpp index 5aa50fe5..b384f68c 100644 --- a/desktop_version/src/Script.cpp +++ b/desktop_version/src/Script.cpp @@ -1850,8 +1850,9 @@ void scriptclass::run(void) i = obj.getplayer(); if (INBOUNDS_VEC(i, obj.entities)) { - obj.entities[i].colour = 0; + obj.entities[i].colour = cl.player_colour; } + game.savecolour = cl.player_colour; } else if (words[0] == "changeplayercolour") { @@ -2652,7 +2653,7 @@ void scriptclass::startgamemode(const enum StartMode mode) } } - /* Containers which need to be reset before gameplay starts + /* State which needs to be reset before gameplay starts * ex. before custom levels get loaded */ switch (mode) @@ -2662,6 +2663,8 @@ void scriptclass::startgamemode(const enum StartMode mode) default: textbox_colours.clear(); add_default_colours(); + cl.onewaycol_override = false; + cl.player_colour = 0; break; } @@ -3207,7 +3210,7 @@ void scriptclass::hardreset(void) game.savey = 0; game.savegc = 0; } - game.savecolour = 0; + game.savecolour = cl.player_colour; game.intimetrial = false; game.timetrialcountdown = 0;