From cd8ea8ad0eb1e8af28c25a75dd2a15bc94c357c4 Mon Sep 17 00:00:00 2001 From: jacob1 Date: Fri, 15 Mar 2013 14:48:01 -0400 Subject: [PATCH 1/3] fix scrollbar not showing in scrollpanels if your mouse starts out already ontop of one --- src/interface/Panel.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/interface/Panel.cpp b/src/interface/Panel.cpp index b78a2cce3..d3bf29bbb 100644 --- a/src/interface/Panel.cpp +++ b/src/interface/Panel.cpp @@ -264,6 +264,7 @@ void Panel::OnMouseMoved(int localx, int localy, int dx, int dy) void Panel::OnMouseMovedInside(int localx, int localy, int dx, int dy) { + mouseInside = true; for(int i = 0; i < children.size(); ++i) { if(!children[i]->Locked) From 2267f3438689e195b38b0f05c8321c713ffd0932 Mon Sep 17 00:00:00 2001 From: jacob1 Date: Fri, 15 Mar 2013 20:32:39 -0400 Subject: [PATCH 2/3] add a button to show the save uploading rules inside the save upload dialog --- src/cat/LegacyLuaAPI.cpp | 3 +- src/dialogues/InformationMessage.cpp | 35 +++++++++++++++++---- src/dialogues/InformationMessage.h | 2 +- src/game/GameController.cpp | 4 +-- src/save/ServerSaveActivity.cpp | 46 +++++++++++++++++++++++++++- src/save/ServerSaveActivity.h | 3 ++ 6 files changed, 82 insertions(+), 11 deletions(-) diff --git a/src/cat/LegacyLuaAPI.cpp b/src/cat/LegacyLuaAPI.cpp index 506c91082..5df660ccb 100644 --- a/src/cat/LegacyLuaAPI.cpp +++ b/src/cat/LegacyLuaAPI.cpp @@ -1632,7 +1632,8 @@ int luatpt_message_box(lua_State* l) { std::string title = std::string(luaL_optstring(l, 1, "Title")); std::string message = std::string(luaL_optstring(l, 2, "Message")); - new InformationMessage(title, message); + int large = luaL_optint(l, 1, 0); + new InformationMessage(title, message, large); return 0; } int luatpt_get_numOfParts(lua_State* l) diff --git a/src/dialogues/InformationMessage.cpp b/src/dialogues/InformationMessage.cpp index 7f861c322..7d11a260d 100644 --- a/src/dialogues/InformationMessage.cpp +++ b/src/dialogues/InformationMessage.cpp @@ -2,21 +2,44 @@ #include "InformationMessage.h" #include "interface/Button.h" #include "interface/Label.h" +#include "interface/ScrollPanel.h" -InformationMessage::InformationMessage(std::string title, std::string message): +InformationMessage::InformationMessage(std::string title, std::string message, bool large): ui::Window(ui::Point(-1, -1), ui::Point(200, 75)) { + if (large) //Maybe also use this large mode for changelogs eventually, or have it as a customizable size? + { + Size.X += 200; + Size.Y += 175; + } + + if (large) + { + ui::ScrollPanel *messagePanel = new ui::ScrollPanel(ui::Point(4, 24), ui::Point(Size.X-8, 206)); + AddComponent(messagePanel); + + ui::Label * messageLabel = new ui::Label(ui::Point(4, 0), ui::Point(Size.X-28, -1), message); + messageLabel->Appearance.HorizontalAlign = ui::Appearance::AlignLeft; + messageLabel->Appearance.VerticalAlign = ui::Appearance::AlignTop; + messageLabel->SetMultiline(true); + messagePanel->AddChild(messageLabel); + + messagePanel->InnerSize = ui::Point(messagePanel->Size.X, messageLabel->Size.Y+4); + } + else + { + ui::Label * messageLabel = new ui::Label(ui::Point(4, 24), ui::Point(Size.X-8, 60), message); + messageLabel->Appearance.HorizontalAlign = ui::Appearance::AlignLeft; + messageLabel->Appearance.VerticalAlign = ui::Appearance::AlignTop; + AddComponent(messageLabel); + } + ui::Label * titleLabel = new ui::Label(ui::Point(4, 5), ui::Point(Size.X-8, 16), title); titleLabel->SetTextColour(style::Colour::InformationTitle); titleLabel->Appearance.HorizontalAlign = ui::Appearance::AlignLeft; titleLabel->Appearance.VerticalAlign = ui::Appearance::AlignMiddle; AddComponent(titleLabel); - ui::Label * messageLabel = new ui::Label(ui::Point(4, 24), ui::Point(Size.X-8, 60), message); - messageLabel->Appearance.HorizontalAlign = ui::Appearance::AlignLeft; - messageLabel->Appearance.VerticalAlign = ui::Appearance::AlignTop; - AddComponent(messageLabel); - class DismissAction: public ui::ButtonAction { InformationMessage * message; diff --git a/src/dialogues/InformationMessage.h b/src/dialogues/InformationMessage.h index 803231113..1df479442 100644 --- a/src/dialogues/InformationMessage.h +++ b/src/dialogues/InformationMessage.h @@ -5,7 +5,7 @@ class InformationMessage: public ui::Window { public: - InformationMessage(std::string title, std::string message); + InformationMessage(std::string title, std::string message, bool large); virtual void OnDraw(); virtual ~InformationMessage(); }; diff --git a/src/game/GameController.cpp b/src/game/GameController.cpp index 993e7689d..017aa5808 100644 --- a/src/game/GameController.cpp +++ b/src/game/GameController.cpp @@ -267,7 +267,7 @@ void GameController::PlaceSave(ui::Point position) void GameController::Install() { #if defined(MACOSX) - new InformationMessage("No Installation necessary", "You don't need to install The Powder Toy on Mac OS X"); + new InformationMessage("No Installation necessary", "You don't need to install The Powder Toy on Mac OS X", false); #elif defined(WIN) || defined(LIN) class InstallConfirmation: public ConfirmDialogueCallback { public: @@ -278,7 +278,7 @@ void GameController::Install() { if(Client::Ref().DoInstallation()) { - new InformationMessage("Install Success", "The installation completed!"); + new InformationMessage("Install Success", "The installation completed!", false); } else { diff --git a/src/save/ServerSaveActivity.cpp b/src/save/ServerSaveActivity.cpp index 94d609a63..f4ec27e20 100644 --- a/src/save/ServerSaveActivity.cpp +++ b/src/save/ServerSaveActivity.cpp @@ -6,6 +6,7 @@ #include "client/requestbroker/RequestBroker.h" #include "dialogues/ErrorMessage.h" #include "dialogues/ConfirmPrompt.h" +#include "dialogues/InformationMessage.h" #include "client/Client.h" #include "tasks/Task.h" #include "Style.h" @@ -33,6 +34,17 @@ public: } }; +class ServerSaveActivity::RulesAction: public ui::ButtonAction +{ + ServerSaveActivity * a; +public: + RulesAction(ServerSaveActivity * a) : a(a) {} + virtual void ActionCallback(ui::Button * sender) + { + a->ShowRules(); + } +}; + class SaveUploadTask: public Task { SaveInfo save; @@ -130,6 +142,14 @@ ServerSaveActivity::ServerSaveActivity(SaveInfo save, ServerSaveActivity::SaveUp AddComponent(okayButton); SetOkayButton(okayButton); + //Position.X+(Size.X/2)+((Size.X/2)-thumbnail->Width)/2, Position.Y+25, thumbnail->Width, thumbnail->Height + ui::Button * RulesButton = new ui::Button(ui::Point((Size.X*3/4)-75, Size.Y-20), ui::Point(150, 16), "Save Uploading Rules"); + RulesButton->Appearance.HorizontalAlign = ui::Appearance::AlignCentre; + RulesButton->Appearance.VerticalAlign = ui::Appearance::AlignMiddle; + RulesButton->Appearance.TextInactive = style::Colour::InformationTitle; + RulesButton->SetActionCallback(new RulesAction(this)); + AddComponent(RulesButton); + if(save.GetGameSave()) RequestBroker::Ref().RenderThumbnail(save.GetGameSave(), false, true, (Size.X/2)-16, -1, this); } @@ -189,7 +209,7 @@ void ServerSaveActivity::Save() { if(Client::Ref().GetAuthUser().Username != save.GetUserName() && publishedCheckbox->GetChecked()) { - new ConfirmPrompt("Publish", "This save was created by " + save.GetUserName() + ", you're about to publish this under your own name; If you haven't been given permission by the author to do so, please untick the publish box, otherwise continue", new PublishConfirmation(this)); + new ConfirmPrompt("Publish", "This save was created by " + save.GetUserName() + ", you're about to publish this under your own name; If you haven't been given permission by the author to do so, please uncheck the publish box, otherwise continue", new PublishConfirmation(this)); } else { @@ -227,6 +247,30 @@ void ServerSaveActivity::Exit() WindowActivity::Exit(); } +void ServerSaveActivity::ShowRules() +{ + const char *rules = + "These are the rules you should follow when uploading saves. They may change at any time as new problems arise, and how each rule is handled changes depending on the situation.\n" + "\n" + "\bt1. No image plotting.\bw If you use a program to draw out pixels from an image outside of TPT without drawing it by hand, then don't be surprised when it gets deleted and you get banned.\n" + "\bt2. No self voting.\bw This means making more than one account, and then using that account to vote on any save multiple times. We can see this stuff, and people get banned for doing this. Don't do it.\n" + "\bt3. No hate saves.\bw This means things like shooting Jews or killing Beiber, these will not be allowed.\n" + "\bt4. No penis drawings.\bw Or any other explicit or non-explicit sex please. We like to think this is a game that kids can play, don't post anything too inappropriate for children.\n" + "\bt5. Don't ask people to vote.\bw If your stuff is awesome, you shouldn't have to beg for popularity to make it so. People tend to downvote when they see a lot of vote begging anyway.\n" + "- This includes vote signs in the game, drawings of vote arrows, and comments on the save telling people to vote up.\n" + "- Gimmicks for getting votes like '100 votes and I'll make a better version' are similarly frowned upon.\n" + "\bt6. Keep the number of logos and signs to a minimum.\bw They not only slow the game down, but it makes saves unappealing for people to use. \n" + "\bt7. Please don't swear excessively.\bw Saves containing excessive swearing or rude language will be unpublished. Don't make rude or offensive comments either.\n" + "\bt8. Don't make text only saves.\bw Saves are much better when they actually use some of the features in the game. Text only saves will be removed from the front page if they should get there.\n" + "- This also relates to art on the front page. Art saves that rely only on the deco layer are generally removed. Other art using elements may stay longer if they are more impressive.\n" + "\bt9. Don't claim other's work as your own.\bw If you didn't make it, don't resave it for yourself. You can fav. a save if you want to see it later instead of publishing a copy.\n" + "- This doesn't mean you can't modify or improve saves, building on the works of others in encouraged. If you give credit to the original author, it is usually ok to do resave unless the author specifically prohibits it.\n" + "\n" + "You can report a save breaking any one of these rules, the moderators are busy in real life too and don't always have the time to search through all the saves for these kinds of things. If reporting a copied save, just give the id of the original, but if not an id isn't needed."; + + new InformationMessage("Save Uploading Rules", rules, true); +} + void ServerSaveActivity::OnTick(float dt) { if(saveUploadTask) diff --git a/src/save/ServerSaveActivity.h b/src/save/ServerSaveActivity.h index 61430743e..feff73570 100644 --- a/src/save/ServerSaveActivity.h +++ b/src/save/ServerSaveActivity.h @@ -28,6 +28,7 @@ public: void saveUpload(); virtual void Save(); virtual void Exit(); + virtual void ShowRules(); virtual void OnDraw(); virtual void OnRequestReady(void * imagePtr); virtual void OnTick(float dt); @@ -44,6 +45,8 @@ protected: ui::Checkbox * pausedCheckbox; class CancelAction; class SaveAction; + class RulesAction; friend class CancelAction; friend class SaveAction; + friend class RulesAction; }; \ No newline at end of file From ff304321c54530040d82cb51b8c8742ed7611e54 Mon Sep 17 00:00:00 2001 From: jacob1 Date: Fri, 15 Mar 2013 21:32:46 -0400 Subject: [PATCH 3/3] new PSTN arms get deco color of the pushing pistons --- src/save/ServerSaveActivity.cpp | 1 - src/simulation/elements/PSTN.cpp | 7 +++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/save/ServerSaveActivity.cpp b/src/save/ServerSaveActivity.cpp index f4ec27e20..1be8c268b 100644 --- a/src/save/ServerSaveActivity.cpp +++ b/src/save/ServerSaveActivity.cpp @@ -142,7 +142,6 @@ ServerSaveActivity::ServerSaveActivity(SaveInfo save, ServerSaveActivity::SaveUp AddComponent(okayButton); SetOkayButton(okayButton); - //Position.X+(Size.X/2)+((Size.X/2)-thumbnail->Width)/2, Position.Y+25, thumbnail->Width, thumbnail->Height ui::Button * RulesButton = new ui::Button(ui::Point((Size.X*3/4)-75, Size.Y-20), ui::Point(150, 16), "Save Uploading Rules"); RulesButton->Appearance.HorizontalAlign = ui::Appearance::AlignCentre; RulesButton->Appearance.VerticalAlign = ui::Appearance::AlignMiddle; diff --git a/src/simulation/elements/PSTN.cpp b/src/simulation/elements/PSTN.cpp index 0f6e916f5..f1c9fd717 100644 --- a/src/simulation/elements/PSTN.cpp +++ b/src/simulation/elements/PSTN.cpp @@ -136,6 +136,13 @@ int Element_PSTN::update(UPDATE_FUNC_ARGS) int nr = sim->create_part(-3, pistonEndX+(nxi*j), pistonEndY+(nyi*j), PT_PSTN); if (nr > -1) { parts[nr].life = 1; + if (parts[i].dcolour) + { + int red = PIXR(parts[i].dcolour)&0xFF; + int green = PIXG(parts[i].dcolour); + int blue = PIXB(parts[i].dcolour); + parts[nr].dcolour = 255<<24|PIXRGB(red>60?red-60:0, green>60?green-60:0, blue>60?blue-60:0); + } } } movedPiston = true;