Merge branch 'master' of github.com:FacialTurd/The-Powder-Toy
This commit is contained in:
commit
0c5e99aef6
1
.gitignore
vendored
1
.gitignore
vendored
@ -32,6 +32,7 @@ Makefile.me
|
||||
*.manifest.res
|
||||
*manifest.rc
|
||||
*res.res
|
||||
*.idb
|
||||
*.obj
|
||||
*.tlog
|
||||
*.lib
|
||||
|
@ -431,7 +431,9 @@ std::vector<std::string> Client::DirectorySearch(std::string directory, std::str
|
||||
findFileHandle = _findfirst(fileMatch.c_str(), ¤tFile);
|
||||
if (findFileHandle == -1L)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
printf("Unable to open directory\n");
|
||||
#endif
|
||||
return std::vector<std::string>();
|
||||
}
|
||||
do
|
||||
@ -1308,7 +1310,7 @@ RequestStatus Client::AddComment(int saveID, std::string comment)
|
||||
|
||||
if(status!=1)
|
||||
{
|
||||
lastError = ((json::Number)objDocument["Error"]).Value();
|
||||
lastError = ((json::String)objDocument["Error"]).Value();
|
||||
}
|
||||
|
||||
if(status!=1)
|
||||
@ -1480,7 +1482,10 @@ RequestStatus Client::UnpublishSave(int saveID)
|
||||
int status = ((json::Number)objDocument["Status"]).Value();
|
||||
|
||||
if(status!=1)
|
||||
{
|
||||
lastError = ((json::String)objDocument["Error"]).Value();
|
||||
goto failure;
|
||||
}
|
||||
}
|
||||
catch (json::Exception &e)
|
||||
{
|
||||
@ -1828,7 +1833,7 @@ Thumbnail * Client::GetThumbnail(int saveID, int saveDate)
|
||||
//Check active requests for any "forgotten" requests
|
||||
for(i = 0; i < IMGCONNS; i++)
|
||||
{
|
||||
//If the request is active, and we've recieved a response
|
||||
//If the request is active, and we've received a response
|
||||
if(activeThumbRequests[i] && http_async_req_status(activeThumbRequests[i]))
|
||||
{
|
||||
//If we haven't already, mark the request as completed
|
||||
|
@ -817,16 +817,27 @@ void GameView::NotifySaveChanged(GameModel * sender)
|
||||
reloadButton->Enabled = true;
|
||||
upVoteButton->Enabled = (sender->GetSave()->GetID() && sender->GetUser().ID && sender->GetSave()->GetVote()==0);
|
||||
if(sender->GetSave()->GetID() && sender->GetUser().ID && sender->GetSave()->GetVote()==1)
|
||||
upVoteButton->Appearance.BackgroundDisabled = (ui::Colour(0, 200, 40, 100));
|
||||
upVoteButton->Appearance.BackgroundDisabled = (ui::Colour(0, 108, 10, 255));
|
||||
else
|
||||
upVoteButton->Appearance.BackgroundDisabled = (ui::Colour(0, 0, 0));
|
||||
|
||||
downVoteButton->Enabled = upVoteButton->Enabled;
|
||||
if(sender->GetSave()->GetID() && sender->GetUser().ID && sender->GetSave()->GetVote()==-1)
|
||||
downVoteButton->Appearance.BackgroundDisabled = (ui::Colour(200, 40, 40, 100));
|
||||
downVoteButton->Appearance.BackgroundDisabled = (ui::Colour(108, 0, 10, 255));
|
||||
else
|
||||
downVoteButton->Appearance.BackgroundDisabled = (ui::Colour(0, 0, 0));
|
||||
|
||||
if (sender->GetUser().ID)
|
||||
{
|
||||
upVoteButton->Appearance.BorderDisabled = upVoteButton->Appearance.BorderInactive;
|
||||
downVoteButton->Appearance.BorderDisabled = downVoteButton->Appearance.BorderInactive;
|
||||
}
|
||||
else
|
||||
{
|
||||
upVoteButton->Appearance.BorderDisabled = ui::Colour(100, 100, 100);
|
||||
downVoteButton->Appearance.BorderDisabled = ui::Colour(100, 100, 100);
|
||||
}
|
||||
|
||||
tagSimulationButton->Enabled = (sender->GetSave()->GetID() && sender->GetUser().ID);
|
||||
if(sender->GetSave()->GetID())
|
||||
{
|
||||
@ -862,9 +873,11 @@ void GameView::NotifySaveChanged(GameModel * sender)
|
||||
saveSimulationButton->SetText(sender->GetSaveFile()->GetDisplayName());
|
||||
reloadButton->Enabled = true;
|
||||
upVoteButton->Enabled = false;
|
||||
upVoteButton->Appearance.BackgroundInactive = (ui::Colour(0, 0, 0));
|
||||
upVoteButton->Appearance.BackgroundDisabled = (ui::Colour(0, 0, 0));
|
||||
upVoteButton->Appearance.BorderDisabled = ui::Colour(100, 100, 100);
|
||||
downVoteButton->Enabled = false;
|
||||
upVoteButton->Appearance.BackgroundInactive = (ui::Colour(0, 0, 0));
|
||||
upVoteButton->Appearance.BackgroundDisabled = (ui::Colour(0, 0, 0));
|
||||
downVoteButton->Appearance.BorderDisabled = ui::Colour(100, 100, 100);
|
||||
tagSimulationButton->Enabled = false;
|
||||
tagSimulationButton->SetText("[no tags set]");
|
||||
currentSaveType = 2;
|
||||
@ -875,9 +888,11 @@ void GameView::NotifySaveChanged(GameModel * sender)
|
||||
saveSimulationButton->SetText("[untitled simulation]");
|
||||
reloadButton->Enabled = false;
|
||||
upVoteButton->Enabled = false;
|
||||
upVoteButton->Appearance.BackgroundInactive = (ui::Colour(0, 0, 0));
|
||||
upVoteButton->Appearance.BackgroundDisabled = (ui::Colour(0, 0, 0));
|
||||
upVoteButton->Appearance.BorderDisabled = ui::Colour(100, 100, 100),
|
||||
downVoteButton->Enabled = false;
|
||||
upVoteButton->Appearance.BackgroundInactive = (ui::Colour(0, 0, 0));
|
||||
upVoteButton->Appearance.BackgroundDisabled = (ui::Colour(0, 0, 0));
|
||||
downVoteButton->Appearance.BorderDisabled = ui::Colour(100, 100, 100),
|
||||
tagSimulationButton->Enabled = false;
|
||||
tagSimulationButton->SetText("[no tags set]");
|
||||
currentSaveType = 0;
|
||||
@ -942,9 +957,9 @@ void GameView::OnMouseMove(int x, int y, int dx, int dy)
|
||||
if(selectMode!=SelectNone)
|
||||
{
|
||||
if(selectMode==PlaceSave)
|
||||
selectPoint1 = c->NormaliseBlockCoord(c->PointTranslate(ui::Point(x, y)));
|
||||
selectPoint1 = c->PointTranslate(ui::Point(x, y));
|
||||
if(selectPoint1.X!=-1)
|
||||
selectPoint2 = c->NormaliseBlockCoord(c->PointTranslate(ui::Point(x, y)));
|
||||
selectPoint2 = c->PointTranslate(ui::Point(x, y));
|
||||
return;
|
||||
}
|
||||
currentMouse = ui::Point(x, y);
|
||||
@ -963,7 +978,7 @@ void GameView::OnMouseDown(int x, int y, unsigned button)
|
||||
{
|
||||
if(button==BUTTON_LEFT)
|
||||
{
|
||||
selectPoint1 = c->NormaliseBlockCoord(c->PointTranslate(ui::Point(x, y)));
|
||||
selectPoint1 = c->PointTranslate(ui::Point(x, y));
|
||||
selectPoint2 = selectPoint1;
|
||||
}
|
||||
return;
|
||||
@ -1023,15 +1038,12 @@ void GameView::OnMouseUp(int x, int y, unsigned button)
|
||||
int y2 = (selectPoint1.Y>selectPoint2.Y)?selectPoint1.Y:selectPoint2.Y;
|
||||
int x1 = (selectPoint2.X<selectPoint1.X)?selectPoint2.X:selectPoint1.X;
|
||||
int y1 = (selectPoint2.Y<selectPoint1.Y)?selectPoint2.Y:selectPoint1.Y;
|
||||
if(x2-x1>0 && y2-y1>0)
|
||||
{
|
||||
if(selectMode==SelectCopy)
|
||||
c->CopyRegion(ui::Point(x1, y1), ui::Point(x2, y2));
|
||||
else if(selectMode==SelectCut)
|
||||
c->CutRegion(ui::Point(x1, y1), ui::Point(x2, y2));
|
||||
else if(selectMode==SelectStamp)
|
||||
c->StampRegion(ui::Point(x1, y1), ui::Point(x2, y2));
|
||||
}
|
||||
if(selectMode==SelectCopy)
|
||||
c->CopyRegion(ui::Point(x1, y1), ui::Point(x2, y2));
|
||||
else if(selectMode==SelectCut)
|
||||
c->CutRegion(ui::Point(x1, y1), ui::Point(x2, y2));
|
||||
else if(selectMode==SelectStamp)
|
||||
c->StampRegion(ui::Point(x1, y1), ui::Point(x2, y2));
|
||||
}
|
||||
}
|
||||
currentMouse = ui::Point(x, y);
|
||||
|
@ -824,9 +824,9 @@ void Graphics::draw_icon(int x, int y, Icon icon, unsigned char alpha, bool inve
|
||||
break;
|
||||
case IconVoteUp:
|
||||
if(invert)
|
||||
drawchar(x, y, 0xCB, 0, 100, 0, alpha);
|
||||
drawchar(x, y+1, 0xCB, 0, 100, 0, alpha);
|
||||
else
|
||||
drawchar(x, y, 0xCB, 0, 187, 18, alpha);
|
||||
drawchar(x, y+1, 0xCB, 0, 187, 18, alpha);
|
||||
break;
|
||||
case IconVoteDown:
|
||||
if(invert)
|
||||
|
@ -84,24 +84,27 @@ void PreviewController::Update()
|
||||
}
|
||||
}
|
||||
|
||||
void PreviewController::SubmitComment(std::string comment)
|
||||
bool PreviewController::SubmitComment(std::string comment)
|
||||
{
|
||||
if(comment.length() < 4)
|
||||
{
|
||||
new ErrorMessage("Error", "Comment is too short");
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
RequestStatus status = Client::Ref().AddComment(saveId, comment);
|
||||
if(status != RequestOkay)
|
||||
{
|
||||
new ErrorMessage("Error Submitting comment", Client::Ref().GetLastError());
|
||||
new ErrorMessage("Error Submitting comment", Client::Ref().GetLastError());
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
previewModel->UpdateComments(1);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void PreviewController::ShowLogin()
|
||||
|
@ -41,7 +41,7 @@ public:
|
||||
PreviewView * GetView() { return previewView; }
|
||||
void Update();
|
||||
void FavouriteSave();
|
||||
void SubmitComment(std::string comment);
|
||||
bool SubmitComment(std::string comment);
|
||||
|
||||
void NextCommentPage();
|
||||
void PrevCommentPage();
|
||||
|
@ -19,6 +19,7 @@
|
||||
#include "search/Thumbnail.h"
|
||||
#include "client/Client.h"
|
||||
#include "interface/ScrollPanel.h"
|
||||
#include "interface/Keys.h"
|
||||
|
||||
class PreviewView::LoginAction: public ui::ButtonAction
|
||||
{
|
||||
@ -121,7 +122,6 @@ PreviewView::PreviewView():
|
||||
openButton->SetIcon(IconOpen);
|
||||
openButton->SetActionCallback(new OpenAction(this));
|
||||
AddComponent(openButton);
|
||||
SetOkayButton(openButton);
|
||||
|
||||
class BrowserOpenAction: public ui::ButtonAction
|
||||
{
|
||||
@ -208,7 +208,6 @@ void PreviewView::commentBoxAutoHeight()
|
||||
int textWidth = Graphics::textwidth(addCommentBox->GetText().c_str());
|
||||
if(textWidth+15 > Size.X-(XRES/2)-48)
|
||||
{
|
||||
addCommentBox->SetMultiline(true);
|
||||
addCommentBox->Appearance.VerticalAlign = ui::Appearance::AlignTop;
|
||||
|
||||
int oldSize = addCommentBox->Size.Y;
|
||||
@ -225,7 +224,6 @@ void PreviewView::commentBoxAutoHeight()
|
||||
else
|
||||
{
|
||||
commentBoxHeight = 20;
|
||||
addCommentBox->SetMultiline(false);
|
||||
addCommentBox->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
|
||||
|
||||
commentBoxPositionX = (XRES/2)+4;
|
||||
@ -365,6 +363,12 @@ void PreviewView::OnMouseWheel(int x, int y, int d)
|
||||
|
||||
}
|
||||
|
||||
void PreviewView::OnKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool alt)
|
||||
{
|
||||
if ((key == KEY_ENTER || key == KEY_RETURN) && !addCommentBox->IsFocused())
|
||||
openButton->DoAction();
|
||||
}
|
||||
|
||||
void PreviewView::NotifySaveChanged(PreviewModel * sender)
|
||||
{
|
||||
SaveInfo * save = sender->GetSave();
|
||||
@ -431,10 +435,11 @@ void PreviewView::submitComment()
|
||||
std::string comment = std::string(addCommentBox->GetText());
|
||||
submitCommentButton->Enabled = false;
|
||||
addCommentBox->SetText("");
|
||||
addCommentBox->SetPlaceholder("Submitting comment");
|
||||
addCommentBox->SetPlaceholder("Submitting comment"); //This doesn't appear to ever show since no separate thread is created
|
||||
FocusComponent(NULL);
|
||||
|
||||
c->SubmitComment(comment);
|
||||
if (!c->SubmitComment(comment))
|
||||
addCommentBox->SetText(comment);
|
||||
|
||||
addCommentBox->SetPlaceholder("Add comment");
|
||||
submitCommentButton->Enabled = true;
|
||||
@ -467,6 +472,7 @@ void PreviewView::NotifyCommentBoxEnabledChanged(PreviewModel * sender)
|
||||
addCommentBox = new ui::Textbox(ui::Point((XRES/2)+4, Size.Y-19), ui::Point(Size.X-(XRES/2)-48, 17), "", "Add Comment");
|
||||
addCommentBox->SetActionCallback(new AutoCommentSizeAction(this));
|
||||
addCommentBox->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
|
||||
addCommentBox->SetMultiline(true);
|
||||
AddComponent(addCommentBox);
|
||||
submitCommentButton = new ui::Button(ui::Point(Size.X-40, Size.Y-19), ui::Point(40, 19), "Submit");
|
||||
submitCommentButton->SetActionCallback(new SubmitCommentAction(this));
|
||||
|
@ -72,6 +72,7 @@ public:
|
||||
virtual void OnTick(float dt);
|
||||
virtual void OnTryExit(ExitMethod method);
|
||||
virtual void OnMouseWheel(int x, int y, int d);
|
||||
virtual void OnKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool alt);
|
||||
virtual ~PreviewView();
|
||||
};
|
||||
|
||||
|
@ -167,7 +167,7 @@ int Simulation::Load(int fullX, int fullY, GameSave * save)
|
||||
|
||||
GameSave * Simulation::Save()
|
||||
{
|
||||
return Save(0, 0, XRES, YRES);
|
||||
return Save(0, 0, XRES-1, YRES-1);
|
||||
}
|
||||
|
||||
GameSave * Simulation::Save(int fullX, int fullY, int fullX2, int fullY2)
|
||||
@ -192,14 +192,14 @@ GameSave * Simulation::Save(int fullX, int fullY, int fullX2, int fullY2)
|
||||
blockX = fullX/CELL;
|
||||
blockY = fullY/CELL;
|
||||
|
||||
blockX2 = fullX2/CELL;
|
||||
blockY2 = fullY2/CELL;
|
||||
blockX2 = (fullX2+CELL)/CELL;
|
||||
blockY2 = (fullY2+CELL)/CELL;
|
||||
|
||||
fullX = blockX*CELL;
|
||||
fullY = blockY*CELL;
|
||||
//fullX = blockX*CELL;
|
||||
//fullY = blockY*CELL;
|
||||
|
||||
fullX2 = blockX2*CELL;
|
||||
fullY2 = blockY2*CELL;
|
||||
//fullX2 = blockX2*CELL;
|
||||
//fullY2 = blockY2*CELL;
|
||||
|
||||
blockW = blockX2-blockX;
|
||||
blockH = blockY2-blockY;
|
||||
@ -216,11 +216,11 @@ GameSave * Simulation::Save(int fullX, int fullY, int fullX2, int fullY2)
|
||||
int x, y;
|
||||
x = int(parts[i].x + 0.5f);
|
||||
y = int(parts[i].y + 0.5f);
|
||||
if(parts[i].type && x >= fullX && y >= fullY && x < fullX2 && y < fullY2)
|
||||
if(parts[i].type && x >= fullX && y >= fullY && x <= fullX2 && y <= fullY2)
|
||||
{
|
||||
Particle tempPart = parts[i];
|
||||
tempPart.x -= fullX;
|
||||
tempPart.y -= fullY;
|
||||
tempPart.x -= blockX*CELL;
|
||||
tempPart.y -= blockY*CELL;
|
||||
if(elements[tempPart.type].Enabled)
|
||||
{
|
||||
*newSave << tempPart;
|
||||
@ -243,11 +243,11 @@ GameSave * Simulation::Save(int fullX, int fullY, int fullX2, int fullY2)
|
||||
|
||||
for(int i = 0; i < MAXSIGNS && i < signs.size(); i++)
|
||||
{
|
||||
if(signs[i].text.length() && signs[i].x >= fullX && signs[i].y >= fullY && signs[i].x < fullX2 && signs[i].y < fullY2)
|
||||
if(signs[i].text.length() && signs[i].x >= fullX && signs[i].y >= fullY && signs[i].x <= fullX2 && signs[i].y <= fullY2)
|
||||
{
|
||||
sign tempSign = signs[i];
|
||||
tempSign.x -= fullX;
|
||||
tempSign.y -= fullY;
|
||||
tempSign.x -= blockX*CELL;
|
||||
tempSign.y -= blockY*CELL;
|
||||
*newSave << tempSign;
|
||||
}
|
||||
}
|
||||
@ -340,9 +340,17 @@ void Simulation::clear_area(int area_x, int area_y, int area_w, int area_h)
|
||||
if(bmap[(cy+area_y)/CELL][(cx+area_x)/CELL] == WL_GRAV)
|
||||
gravWallChanged = true;
|
||||
bmap[(cy+area_y)/CELL][(cx+area_x)/CELL] = 0;
|
||||
emap[(cy+area_y)/CELL][(cx+area_x)/CELL] = 0;
|
||||
delete_part(cx+area_x, cy+area_y, 0);
|
||||
}
|
||||
}
|
||||
for(int i = 0; i < MAXSIGNS && i < signs.size(); i++)
|
||||
{
|
||||
if(signs[i].text.length() && signs[i].x >= area_x && signs[i].y >= area_y && signs[i].x <= area_x+area_w && signs[i].y <= area_y+area_h)
|
||||
{
|
||||
signs.erase(signs.begin()+i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Simulation::CreateBox(int x1, int y1, int x2, int y2, int c, int flags)
|
||||
|
@ -80,13 +80,14 @@ int Element_MERC::update(UPDATE_FUNC_ARGS)
|
||||
r = pmap[y+ry][x+rx];
|
||||
if (parts[i].tmp<=maxtmp)
|
||||
continue;
|
||||
if ((!r)&&parts[i].tmp>=1)//if nothing then create deut
|
||||
if ((!r)&&parts[i].tmp>=1)//if nothing then create MERC
|
||||
{
|
||||
np = sim->create_part(-1,x+rx,y+ry,PT_MERC);
|
||||
if (np<0) continue;
|
||||
parts[i].tmp--;
|
||||
parts[np].temp = parts[i].temp;
|
||||
parts[np].tmp = 0;
|
||||
parts[np].dcolour = parts[i].dcolour;
|
||||
}
|
||||
}
|
||||
for ( trade = 0; trade<4; trade ++)
|
||||
@ -118,4 +119,4 @@ int Element_MERC::update(UPDATE_FUNC_ARGS)
|
||||
}
|
||||
|
||||
|
||||
Element_MERC::~Element_MERC() {}
|
||||
Element_MERC::~Element_MERC() {}
|
||||
|
Reference in New Issue
Block a user