Testing
This commit is contained in:
parent
5b5feca0ea
commit
b53fc267cb
@ -6,8 +6,6 @@
|
|||||||
#include "Graphics.h"
|
#include "Graphics.h"
|
||||||
#include "../Utilities.h"
|
#include "../Utilities.h"
|
||||||
|
|
||||||
std::vector<Color> Graphics::Palette;
|
|
||||||
|
|
||||||
|
|
||||||
Graphics::Graphics(int screenWidth, int screenHeight, int startupScale) : m_screenWidth(screenWidth), m_screenHeight(screenHeight){
|
Graphics::Graphics(int screenWidth, int screenHeight, int startupScale) : m_screenWidth(screenWidth), m_screenHeight(screenHeight){
|
||||||
m_startupScreenWidth = screenWidth * startupScale;
|
m_startupScreenWidth = screenWidth * startupScale;
|
||||||
@ -36,7 +34,6 @@ void Graphics::draw(StateManager* stateManager) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
BeginTextureMode(m_virtualScreen);
|
BeginTextureMode(m_virtualScreen);
|
||||||
|
|
||||||
stateManager->Draw(this);
|
stateManager->Draw(this);
|
||||||
|
|
||||||
EndTextureMode();
|
EndTextureMode();
|
||||||
@ -56,8 +53,14 @@ void Graphics::loadPalette(std::string path) {
|
|||||||
std::string line;
|
std::string line;
|
||||||
|
|
||||||
if(paletteFile.is_open()){
|
if(paletteFile.is_open()){
|
||||||
|
int idx = 0;
|
||||||
while(getline(paletteFile, line)){
|
while(getline(paletteFile, line)){
|
||||||
Palette.push_back(Utilities::ColorFromHex(stoi(line, nullptr, 16)));
|
int color = stoi(line, nullptr, 16);
|
||||||
|
//Palette.push_back();
|
||||||
|
color = color << 8 | 0xFF;
|
||||||
|
m_paletteByColor.insert({color, idx});
|
||||||
|
m_paletteByID.insert({idx, color});
|
||||||
|
idx++;
|
||||||
}
|
}
|
||||||
paletteFile.close();
|
paletteFile.close();
|
||||||
}
|
}
|
||||||
@ -161,24 +164,24 @@ void Graphics::bindMethods(pkpy::VM *vm) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Graphics::Clear(int paletteIndex) {
|
void Graphics::Clear(int paletteIndex) {
|
||||||
if(paletteIndex < 0 || paletteIndex >= Palette.size()) paletteIndex = 0;
|
if(paletteIndex < 0 || paletteIndex >= m_paletteByID.size()) paletteIndex = 0;
|
||||||
ClearBackground(Palette[paletteIndex]);
|
ClearBackground(GetColor(m_paletteByID[paletteIndex]));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Graphics::Pixel(int x, int y, int paletteIndex) {
|
void Graphics::Pixel(int x, int y, int paletteIndex) {
|
||||||
DrawPixel(x, y, Palette[paletteIndex]);
|
DrawPixel(x, y, GetColor(m_paletteByID[paletteIndex]));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Graphics::Circle(int x, int y, int radius, int paletteIndex) {
|
void Graphics::Circle(int x, int y, int radius, int paletteIndex) {
|
||||||
DrawCircle(x, y, radius, Palette[paletteIndex]);
|
DrawCircle(x, y, radius, GetColor(m_paletteByID[paletteIndex]));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Graphics::Rect(int x, int y, int width, int height, int paletteIndex) {
|
void Graphics::Rect(int x, int y, int width, int height, int paletteIndex) {
|
||||||
DrawRectangle(x, y, width, height, Palette[paletteIndex]);
|
DrawRectangle(x, y, width, height, GetColor(m_paletteByID[paletteIndex]));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Graphics::Text(std::string s, int x, int y, int paletteIndex) {
|
void Graphics::Text(std::string s, int x, int y, int paletteIndex) {
|
||||||
DrawText(s.c_str(), x, y, 5, Palette[paletteIndex]);
|
DrawText(s.c_str(), x, y, 5, GetColor(m_paletteByID[paletteIndex]));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Graphics::beginDraw() {
|
void Graphics::beginDraw() {
|
||||||
|
|||||||
@ -4,6 +4,7 @@
|
|||||||
#include "../StateManager.h"
|
#include "../StateManager.h"
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include <unordered_map>
|
||||||
|
|
||||||
class StateManager;
|
class StateManager;
|
||||||
|
|
||||||
@ -34,7 +35,9 @@ public:
|
|||||||
|
|
||||||
bool m_windowShouldClose = false;
|
bool m_windowShouldClose = false;
|
||||||
|
|
||||||
static std::vector<Color> Palette;
|
|
||||||
|
std::unordered_map<unsigned int, unsigned int> m_paletteByColor; // <hex color, id>
|
||||||
|
std::unordered_map<unsigned int, unsigned int> m_paletteByID; // <id, hex color>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user