Corrections to GameSave to prevent conflicts in the Expanded state, improve Save preview comments display
This commit is contained in:
parent
ca1f81a264
commit
c14a008d46
@ -85,6 +85,9 @@ GameSave::GameSave(std::vector<char> data)
|
||||
expanded = false;
|
||||
hasOriginalData = true;
|
||||
originalData = data;
|
||||
#ifdef DEBUG
|
||||
std::cout << "Creating Collapsed save from data" << std::endl;
|
||||
#endif
|
||||
try
|
||||
{
|
||||
Expand();
|
||||
@ -114,6 +117,9 @@ GameSave::GameSave(std::vector<unsigned char> data)
|
||||
expanded = false;
|
||||
hasOriginalData = true;
|
||||
originalData = std::vector<char>(data.begin(), data.end());
|
||||
#ifdef DEBUG
|
||||
std::cout << "Creating Collapsed save from data" << std::endl;
|
||||
#endif
|
||||
try
|
||||
{
|
||||
Expand();
|
||||
@ -140,9 +146,12 @@ GameSave::GameSave(char * data, int dataSize)
|
||||
fanVelYPtr = NULL;
|
||||
particles = NULL;
|
||||
|
||||
expanded = true;
|
||||
expanded = false;
|
||||
hasOriginalData = true;
|
||||
originalData = std::vector<char>(data, data+dataSize);
|
||||
#ifdef DEBUG
|
||||
std::cout << "Creating Expanded save from data" << std::endl;
|
||||
#endif
|
||||
try
|
||||
{
|
||||
Expand();
|
||||
@ -219,10 +228,16 @@ void GameSave::read(char * data, int dataSize)
|
||||
{
|
||||
if(data[0] == 0x50 || data[0] == 0x66)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
std::cout << "Reading PSv..." << std::endl;
|
||||
#endif
|
||||
readPSv(data, dataSize);
|
||||
}
|
||||
else if(data[0] == 'O')
|
||||
{
|
||||
#ifdef DEBUG
|
||||
std::cout << "Reading OPS..." << std::endl;
|
||||
#endif
|
||||
readOPS(data, dataSize);
|
||||
}
|
||||
else
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include <cmath>
|
||||
#include <iostream>
|
||||
#include <bzlib.h>
|
||||
#include <string>
|
||||
#include "Config.h"
|
||||
@ -330,6 +331,9 @@ pixel *Graphics::resample_img_nn(pixel * src, int sw, int sh, int rw, int rh)
|
||||
|
||||
pixel *Graphics::resample_img(pixel *src, int sw, int sh, int rw, int rh)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
std::cout << "Resampling " << sw << "x" << sh << " to " << rw << "x" << rh << std::endl;
|
||||
#endif
|
||||
int y, x, fxceil, fyceil;
|
||||
//int i,j,x,y,w,h,r,g,b,c;
|
||||
pixel *q = NULL;
|
||||
@ -337,7 +341,7 @@ pixel *Graphics::resample_img(pixel *src, int sw, int sh, int rw, int rh)
|
||||
//Don't resample
|
||||
q = (pixel *)malloc(rw*rh*PIXELSIZE);
|
||||
memcpy(q, src, rw*rh*PIXELSIZE);
|
||||
} else if(rw > sw && rh > sh){
|
||||
} else if(rw >= sw && rh >= sh){
|
||||
float fx, fy, fyc, fxc;
|
||||
double intp;
|
||||
pixel tr, tl, br, bl;
|
||||
@ -376,14 +380,16 @@ pixel *Graphics::resample_img(pixel *src, int sw, int sh, int rw, int rh)
|
||||
rw = sw;
|
||||
rh = sh;
|
||||
while(rrw != rw && rrh != rh){
|
||||
rw *= 0.7;
|
||||
rh *= 0.7;
|
||||
if(rw <= rrw || rh <= rrh){
|
||||
if(rw > rrw)
|
||||
rw *= 0.7;
|
||||
if(rh > rrh)
|
||||
rh *= 0.7;
|
||||
if(rw <= rrw)
|
||||
rw = rrw;
|
||||
if(rh <= rrh)
|
||||
rh = rrh;
|
||||
}
|
||||
q = (pixel *)malloc(rw*rh*PIXELSIZE);
|
||||
//Bilinear interpolation for upscaling
|
||||
//Bilinear interpolation
|
||||
for (y=0; y<rh; y++)
|
||||
for (x=0; x<rw; x++)
|
||||
{
|
||||
|
@ -31,8 +31,10 @@ void ScrollPanel::XOnMouseWheelInside(int localx, int localy, int d)
|
||||
yScrollVel -= d*2;
|
||||
}
|
||||
|
||||
void ScrollPanel::XDraw(const Point& screenPos)
|
||||
void ScrollPanel::Draw(const Point& screenPos)
|
||||
{
|
||||
Panel::Draw(screenPos);
|
||||
|
||||
Graphics * g = ui::Engine::Ref().g;
|
||||
|
||||
//Vertical scroll bar
|
||||
@ -45,7 +47,7 @@ void ScrollPanel::XDraw(const Point& screenPos)
|
||||
scrollPos = float(Size.Y-scrollHeight)*(float(offsetY)/float(maxOffset.Y));
|
||||
}
|
||||
|
||||
g->fillrect(screenPos.X+(Size.X-scrollBarWidth), screenPos.Y, scrollBarWidth, Size.Y, 255, 255, 255, 55);
|
||||
g->fillrect(screenPos.X+(Size.X-scrollBarWidth), screenPos.Y, scrollBarWidth, Size.Y, 125, 125, 125, 100);
|
||||
g->fillrect(screenPos.X+(Size.X-scrollBarWidth), screenPos.Y+scrollPos, scrollBarWidth, scrollHeight, 255, 255, 255, 255);
|
||||
}
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ namespace ui
|
||||
|
||||
int GetScrollLimit();
|
||||
|
||||
virtual void XDraw(const Point& screenPos);
|
||||
virtual void Draw(const Point& screenPos);
|
||||
virtual void XTick(float dt);
|
||||
virtual void XOnMouseWheelInside(int localx, int localy, int d);
|
||||
};
|
||||
|
@ -156,7 +156,7 @@ PreviewView::PreviewView():
|
||||
pageInfo = new ui::Label(ui::Point((XRES/2) + 5, Size.Y+1), ui::Point(Size.X-((XRES/2) + 10), 15), "Page 1 of 1");
|
||||
pageInfo->Appearance.HorizontalAlign = ui::Appearance::AlignCentre; authorDateLabel->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
|
||||
|
||||
commentsPanel = new ui::ScrollPanel(ui::Point(XRES/2, 0), ui::Point(Size.X-(XRES/2), Size.Y-commentBoxHeight));
|
||||
commentsPanel = new ui::ScrollPanel(ui::Point((XRES/2)+1, 1), ui::Point((Size.X-(XRES/2))-2, Size.Y-commentBoxHeight));
|
||||
AddComponent(commentsPanel);
|
||||
|
||||
AddComponent(pageInfo);
|
||||
@ -202,6 +202,18 @@ void PreviewView::DoDraw()
|
||||
g->drawrect(Position.X+(Size.X/2)-100, Position.Y+(Size.Y/2)-25, 200, 50, 255, 255, 255, 180);
|
||||
g->drawtext(Position.X+(Size.X/2)-(Graphics::textwidth("Loading save...")/2), Position.Y+(Size.Y/2)-5, "Loading save...", style::Colour::InformationTitle.Red, style::Colour::InformationTitle.Green, style::Colour::InformationTitle.Blue, 255);
|
||||
}
|
||||
|
||||
for(int i = 0; i < commentTextComponents.size(); i++)
|
||||
{
|
||||
int linePos = commentTextComponents[i]->Position.Y+commentsPanel->ViewportPosition.Y+commentTextComponents[i]->Size.Y+4;
|
||||
if(linePos > 0 && linePos < Size.Y-commentBoxHeight)
|
||||
g->draw_line(
|
||||
Position.X+1+XRES/2,
|
||||
Position.Y+linePos,
|
||||
Position.X+Size.X-2,
|
||||
Position.Y+linePos,
|
||||
255, 255, 255, 100);
|
||||
}
|
||||
}
|
||||
|
||||
void PreviewView::OnDraw()
|
||||
@ -218,7 +230,7 @@ void PreviewView::OnDraw()
|
||||
g->draw_image(savePreview->Data, (Position.X+1)+(((XRES/2)-savePreview->Size.X)/2), (Position.Y+1)+(((YRES/2)-savePreview->Size.Y)/2), savePreview->Size.X, savePreview->Size.Y, 255);
|
||||
}
|
||||
g->drawrect(Position.X, Position.Y, (XRES/2)+1, (YRES/2)+1, 255, 255, 255, 100);
|
||||
g->draw_line(Position.X+1+XRES/2, Position.Y+1, Position.X+1+XRES/2, Position.Y+Size.Y-2, 200, 200, 200, 255);
|
||||
g->draw_line(Position.X+XRES/2, Position.Y+1, Position.X+XRES/2, Position.Y+Size.Y-2, 200, 200, 200, 255);
|
||||
|
||||
|
||||
g->draw_line(Position.X+1, Position.Y+12+YRES/2, Position.X-1+XRES/2, Position.Y+12+YRES/2, 100, 100, 100,255);
|
||||
@ -233,18 +245,6 @@ void PreviewView::OnDraw()
|
||||
g->draw_icon(1+Position.X+2, Position.Y+(YRES/2)+4, IconVoteUp);
|
||||
g->draw_icon(Position.X+(XRES/2)-12, Position.Y+(YRES/2)+1, IconVoteDown);
|
||||
}
|
||||
|
||||
for(int i = 0; i < commentTextComponents.size(); i++)
|
||||
{
|
||||
int linePos = commentTextComponents[i]->Position.Y+commentsPanel->ViewportPosition.Y+commentTextComponents[i]->Size.Y+4;
|
||||
if(linePos > 0 && linePos < Size.Y-commentBoxHeight)
|
||||
g->draw_line(
|
||||
Position.X+XRES/2,
|
||||
Position.Y+linePos,
|
||||
Position.X+Size.X-1,
|
||||
Position.Y+linePos,
|
||||
100, 100, 100, 255);
|
||||
}
|
||||
}
|
||||
|
||||
void PreviewView::OnTick(float dt)
|
||||
|
Reference in New Issue
Block a user