diff --git a/Makefile b/Makefile index 490dda7b2..4c11e2b40 100644 --- a/Makefile +++ b/Makefile @@ -39,7 +39,7 @@ build/powder-release: $(SOURCES) strip $@ build/powder.exe: buildpaths-powder.exe $(patsubst build/obj/%.o,build/obj/powder.exe/%.o,$(OBJS)) - $(CPP_WINC) $(CFLAGS) $(OFLAGS) $(LDFLAGS) $(patsubst build/obj/%.o,build/obj/powder.exe/%.o,$(OBJS)) $(LFLAGS) -o $@ -ggdb + $(CPPC_WIN) $(CFLAGS) $(OFLAGS) $(LDFLAGS) $(patsubst build/obj/%.o,build/obj/powder.exe/%.o,$(OBJS)) $(LFLAGS) -o $@ -ggdb build/obj/powder.exe/%.o: src/%.cpp $(HEADERS) $(CPPC_WIN) -c $(CFLAGS) $(OFLAGS) -o $@ $< -ggdb buildpaths-powder.exe: diff --git a/src/Graphics.cpp b/src/Graphics.cpp index a48f6d62e..678e13896 100644 --- a/src/Graphics.cpp +++ b/src/Graphics.cpp @@ -1141,20 +1141,54 @@ TPT_INLINE void Graphics::blendpixel(int x, int y, int r, int g, int b, int a) #endif } -void Graphics::draw_icon(int x, int y, char ch, int flag) +void Graphics::draw_icon(int x, int y, Icon icon) { - char t[2]; - t[0] = ch; - t[1] = 0; - if (flag) + switch(icon) { - fillrect(x-1, y-1, 17, 17, 255, 255, 255, 255); - drawtext(x+3, y+2, t, 0, 0, 0, 255); - } - else - { - drawrect(x, y, 15, 15, 255, 255, 255, 255); - drawtext(x+3, y+2, t, 255, 255, 255, 255); + case IconOpen: + drawchar(x, y, 0x81, 255, 255, 255, 255); + break; + case IconReload: + drawchar(x, y, 0x91, 255, 255, 255, 255); + break; + case IconSave: + drawchar(x, y, 0x82, 255, 255, 255, 255); + break; + case IconVoteUp: + drawchar(x, y, 0xCB, 0, 187, 18, 255); + break; + case IconVoteDown: + drawchar(x, y, 0xCA, 187, 40, 0, 255); + break; + case IconTag: + drawchar(x, y, 0x83, 255, 255, 255, 255); + break; + case IconNew: + drawchar(x, y, 0x92, 255, 255, 255, 255); + break; + case IconLogin: + drawchar(x, y, 0x84, 255, 255, 255, 255); + break; + case IconSimulationSettings: + drawchar(x, y, 0xCF, 255, 255, 255, 255); + break; + case IconRenderSettings: + addchar(x, y, 0xD8, 255, 0, 0, 255); + addchar(x, y, 0xD9, 0, 255, 0, 255); + addchar(x, y, 0xDA, 0, 0, 255, 255); + break; + case IconPause: + drawchar(x, y, 0x90, 255, 255, 255, 255); + break; + case IconVoteSort: + case IconDateSort: + case IconFavourite: + case IconFolder: + case IconSearch: + case IconDelete: + default: + drawchar(x, y, 't', 255, 255, 255, 255); + break; } } diff --git a/src/Graphics.h b/src/Graphics.h index 25cb5d67f..d2f97219f 100644 --- a/src/Graphics.h +++ b/src/Graphics.h @@ -52,38 +52,28 @@ typedef unsigned short pixel; typedef unsigned int pixel; #endif -/*extern int emp_decor; - -extern unsigned int *render_modes; -extern unsigned int render_mode; -extern unsigned int colour_mode; -extern unsigned int *display_modes; -extern unsigned int display_mode; - -extern SDL_Surface *sdl_scrn; -extern int sdl_scale; - -extern int sandcolour_r; -extern int sandcolour_g; -extern int sandcolour_b; -extern int sandcolour_frame; - -extern unsigned char fire_r[YRES/CELL][XRES/CELL]; -extern unsigned char fire_g[YRES/CELL][XRES/CELL]; -extern unsigned char fire_b[YRES/CELL][XRES/CELL]; - -extern unsigned int fire_alpha[CELL*3][CELL*3]; -extern pixel *pers_bg; - -extern char * flm_data; -extern int flm_data_points; -extern pixel flm_data_colours[]; -extern float flm_data_pos[]; - -extern char * plasma_data; -extern int plasma_data_points; -extern pixel plasma_data_colours[]; -extern float plasma_data_pos[];*/ +//Icon names, see Graphics::draw_icon +enum Icon +{ + NoIcon = 0, + IconOpen, + IconReload, + IconSave, + IconVoteUp, + IconVoteDown, + IconTag, + IconNew, + IconLogin, + IconRenderSettings, + IconSimulationSettings, + IconPause, + IconVoteSort, + IconDateSort, + IconFavourite, + IconFolder, + IconSearch, + IconDelete +}; class Graphics { @@ -126,7 +116,7 @@ public: static int textposxy(char *s, int width, int w, int h); static int textwrapheight(char *s, int width); inline void blendpixel(int x, int y, int r, int g, int b, int a); - void draw_icon(int x, int y, char ch, int flag); + void draw_icon(int x, int y, Icon icon); //void draw_air(); //void draw_grav_zones(pixel *vid); //void draw_grav(pixel *vid); diff --git a/src/elements/bomb.cpp b/src/elements/bomb.cpp index b696b1916..3b6db267c 100644 --- a/src/elements/bomb.cpp +++ b/src/elements/bomb.cpp @@ -11,7 +11,7 @@ int update_BOMB(UPDATE_FUNC_ARGS) { r = pmap[y+ry][x+rx]; if (!r) continue; - if (sim->ptypes[r&0xFF].properties & (TYPE_SOLID | TYPE_PART | TYPE_LIQUID) && !(sim->ptypes[r&0xFF].properties & PROP_SPARKSETTLE)) { + if ((sim->ptypes[r&0xFF].properties & (TYPE_SOLID | TYPE_PART | TYPE_LIQUID)) && !(sim->ptypes[r&0xFF].properties & PROP_SPARKSETTLE)) { sim->kill_part(i); return 1; } diff --git a/src/elements/newgraphics.cpp b/src/elements/newgraphics.cpp index 036a6a7d2..efdf12883 100644 --- a/src/elements/newgraphics.cpp +++ b/src/elements/newgraphics.cpp @@ -357,7 +357,7 @@ int graphics_GLOW(GRAPHICS_FUNC_ARGS) } int graphics_LCRY(GRAPHICS_FUNC_ARGS) { - if(ren->decorations_enable && cpart->dcolour && cpart->dcolour&0xFF000000) + if(ren->decorations_enable && cpart->dcolour && (cpart->dcolour&0xFF000000)) { *colr = (cpart->dcolour>>16)&0xFF; *colg = (cpart->dcolour>>8)&0xFF; diff --git a/src/elements/stkm.cpp b/src/elements/stkm.cpp index c457b6202..68ef1ed9a 100644 --- a/src/elements/stkm.cpp +++ b/src/elements/stkm.cpp @@ -78,6 +78,7 @@ int run_stickman(playerst* playerp, UPDATE_FUNC_ARGS) { gvx = ((float)(parts[i].x - XCNTR) / gravd); gvy = ((float)(parts[i].y - YCNTR) / gravd); } + break; } gvx += sim->gravx[((int)parts[i].y/CELL)*(XRES/CELL)+((int)parts[i].x/CELL)]; diff --git a/src/elements/wire.cpp b/src/elements/wire.cpp index f7202e434..c3c918b6b 100644 --- a/src/elements/wire.cpp +++ b/src/elements/wire.cpp @@ -64,4 +64,5 @@ int graphics_WIRE(GRAPHICS_FUNC_ARGS) //*pixel_mode |= PMODE_GLOW; return 0; } + return 0; } diff --git a/src/game/GameView.cpp b/src/game/GameView.cpp index 3f3155430..3a20b3e12 100644 --- a/src/game/GameView.cpp +++ b/src/game/GameView.cpp @@ -25,7 +25,8 @@ GameView::GameView(): v->c->OpenSearch(); } }; - searchButton = new ui::Button(ui::Point(currentX, Size.Y-18), ui::Point(16, 16), "\x81"); //Open + searchButton = new ui::Button(ui::Point(currentX, Size.Y-18), ui::Point(16, 16)); //Open + searchButton->SetIcon(IconOpen); currentX+=18; searchButton->SetTogglable(false); searchButton->SetActionCallback(new SearchAction(this)); @@ -41,7 +42,8 @@ GameView::GameView(): v->c->ReloadSim(); } }; - reloadButton = new ui::Button(ui::Point(currentX, Size.Y-18), ui::Point(16, 16), "\x91"); + reloadButton = new ui::Button(ui::Point(currentX, Size.Y-18), ui::Point(16, 16)); + reloadButton->SetIcon(IconReload); currentX+=18; reloadButton->SetActionCallback(new ReloadAction(this)); AddComponent(reloadButton); @@ -56,7 +58,8 @@ GameView::GameView(): v->c->OpenSaveWindow(); } }; - saveSimulationButton = new ui::Button(ui::Point(currentX, Size.Y-18), ui::Point(Size.X/5, 16), "\x82"); + saveSimulationButton = new ui::Button(ui::Point(currentX, Size.Y-18), ui::Point(Size.X/5, 16)); + saveSimulationButton->SetIcon(IconSave); currentX+=(Size.X/5)+2; saveSimulationButton->SetActionCallback(new SaveSimulationAction(this)); AddComponent(saveSimulationButton); @@ -71,7 +74,8 @@ GameView::GameView(): v->c->Vote(1); } }; - upVoteButton = new ui::Button(ui::Point(currentX, Size.Y-18), ui::Point(16, 16), "\xCB"); + upVoteButton = new ui::Button(ui::Point(currentX, Size.Y-18), ui::Point(16, 16)); + upVoteButton->SetIcon(IconVoteUp); currentX+=16; upVoteButton->SetActionCallback(new UpVoteAction(this)); AddComponent(upVoteButton); @@ -86,7 +90,8 @@ GameView::GameView(): v->c->Vote(-1); } }; - downVoteButton = new ui::Button(ui::Point(currentX, Size.Y-18), ui::Point(16, 16), "\xCA"); + downVoteButton = new ui::Button(ui::Point(currentX, Size.Y-18), ui::Point(16, 16)); + downVoteButton->SetIcon(IconVoteDown); currentX+=18; downVoteButton->SetActionCallback(new DownVoteAction(this)); AddComponent(downVoteButton); @@ -101,7 +106,8 @@ GameView::GameView(): v->c->OpenTags(); } }; - tagSimulationButton = new ui::Button(ui::Point(currentX, Size.Y-18), ui::Point(Size.X-(currentX+176), 16), "\x83"); + tagSimulationButton = new ui::Button(ui::Point(currentX, Size.Y-18), ui::Point(Size.X-(currentX+176), 16)); + tagSimulationButton->SetIcon(IconTag); currentX+=Size.X-(currentX+176); tagSimulationButton->SetActionCallback(new TagSimulationAction(this)); AddComponent(tagSimulationButton); @@ -116,7 +122,8 @@ GameView::GameView(): v->c->ClearSim(); } }; - clearSimButton = new ui::Button(ui::Point(Size.X-174, Size.Y-18), ui::Point(16, 16), "C"); + clearSimButton = new ui::Button(ui::Point(Size.X-174, Size.Y-18), ui::Point(16, 16)); + clearSimButton->SetIcon(IconNew); clearSimButton->SetActionCallback(new ClearSimAction(this)); AddComponent(clearSimButton); @@ -130,7 +137,8 @@ GameView::GameView(): v->c->OpenLogin(); } }; - loginButton = new ui::Button(ui::Point(Size.X-156, Size.Y-18), ui::Point(100, 16), "\xDA Login"); + loginButton = new ui::Button(ui::Point(Size.X-156, Size.Y-18), ui::Point(100, 16), "Login"); + loginButton->SetIcon(IconLogin); loginButton->SetActionCallback(new LoginAction(this)); AddComponent(loginButton); @@ -144,7 +152,8 @@ GameView::GameView(): v->c->OpenDisplayOptions(); } }; - simulationOptionButton = new ui::Button(ui::Point(Size.X-54, Size.Y-18), ui::Point(16, 16), "\xDA"); + simulationOptionButton = new ui::Button(ui::Point(Size.X-54, Size.Y-18), ui::Point(16, 16)); + simulationOptionButton->SetIcon(IconSimulationSettings); simulationOptionButton->SetActionCallback(new SimulationOptionAction(this)); AddComponent(simulationOptionButton); @@ -158,7 +167,8 @@ GameView::GameView(): v->c->OpenRenderOptions(); } }; - displayModeButton = new ui::Button(ui::Point(Size.X-36, Size.Y-18), ui::Point(16, 16), "\xDA"); + displayModeButton = new ui::Button(ui::Point(Size.X-36, Size.Y-18), ui::Point(16, 16)); + displayModeButton->SetIcon(IconRenderSettings); displayModeButton->SetActionCallback(new DisplayModeAction(this)); AddComponent(displayModeButton); @@ -172,7 +182,8 @@ GameView::GameView(): v->c->SetPaused(sender->GetToggleState()); } }; - pauseButton = new ui::Button(ui::Point(Size.X-18, Size.Y-18), ui::Point(16, 16), "\x90"); //Pause + pauseButton = new ui::Button(ui::Point(Size.X-18, Size.Y-18), ui::Point(16, 16)); //Pause + pauseButton->SetIcon(IconPause); pauseButton->SetTogglable(true); pauseButton->SetActionCallback(new PauseAction(this)); AddComponent(pauseButton); @@ -204,7 +215,7 @@ public: void GameView::NotifyMenuListChanged(GameModel * sender) { - int currentY = YRES+MENUSIZE-36; + int currentY = YRES+MENUSIZE-18-(sender->GetMenuList().size()*18); for(int i = 0; i < menuButtons.size(); i++) { RemoveComponent(menuButtons[i]); @@ -225,7 +236,7 @@ void GameView::NotifyMenuListChanged(GameModel * sender) ui::Button * tempButton = new ui::Button(ui::Point(XRES+BARSIZE-18, currentY), ui::Point(16, 16), tempString); tempButton->SetTogglable(true); tempButton->SetActionCallback(new MenuAction(this, menuList[i])); - currentY-=18; + currentY+=18; AddComponent(tempButton); menuButtons.push_back(tempButton); } diff --git a/src/interface/Button.cpp b/src/interface/Button.cpp index b145b38fa..b4e32b29c 100644 --- a/src/interface/Button.cpp +++ b/src/interface/Button.cpp @@ -15,24 +15,6 @@ namespace ui { -Button::Button(Window* parent_state, std::string buttonText): - Component(parent_state), - ButtonText(buttonText), - isMouseInside(false), - isButtonDown(false), - isTogglable(false), - toggle(false), - actionCallback(NULL), - textPosition(ui::Point(0, 0)), - textVAlign(AlignMiddle), - textHAlign(AlignCentre), - Enabled(true) -{ - activeText = background = Colour(0, 0, 0); - text = activeBackground = border = activeBorder = Colour(255, 255, 255); - TextPosition(); -} - Button::Button(Point position, Point size, std::string buttonText): Component(position, size), ButtonText(buttonText), @@ -44,25 +26,8 @@ Button::Button(Point position, Point size, std::string buttonText): textPosition(ui::Point(0, 0)), textVAlign(AlignMiddle), textHAlign(AlignCentre), - Enabled(true) -{ - activeText = background = Colour(0, 0, 0); - text = activeBackground = border = activeBorder = Colour(255, 255, 255); - TextPosition(); -} - -Button::Button(std::string buttonText): - Component(), - ButtonText(buttonText), - isMouseInside(false), - isButtonDown(false), - isTogglable(false), - toggle(false), - actionCallback(NULL), - textPosition(ui::Point(0, 0)), - textVAlign(AlignMiddle), - textHAlign(AlignCentre), - Enabled(true) + Enabled(true), + icon(NoIcon) { activeText = background = Colour(0, 0, 0); text = activeBackground = border = activeBorder = Colour(255, 255, 255); @@ -71,7 +36,6 @@ Button::Button(std::string buttonText): void Button::TextPosition() { - //Position.X+(Size.X-Graphics::textwidth((char *)ButtonText.c_str()))/2, Position.Y+(Size.Y-10)/2 switch(textVAlign) { case AlignTop: @@ -85,18 +49,42 @@ void Button::TextPosition() break; } - switch(textHAlign) + if(icon) { - case AlignLeft: - textPosition.X = 3; - break; - case AlignCentre: - textPosition.X = (Size.X-Graphics::textwidth((char *)ButtonText.c_str()))/2; - break; - case AlignRight: - textPosition.X = (Size.X-Graphics::textwidth((char *)ButtonText.c_str()))-2; - break; + switch(textHAlign) + { + case AlignLeft: + textPosition.X = 3+17; + break; + case AlignCentre: + textPosition.X = (((Size.X-14)-Graphics::textwidth((char *)ButtonText.c_str()))/2)+17; + break; + case AlignRight: + textPosition.X = (((Size.X-14)-Graphics::textwidth((char *)ButtonText.c_str()))-2)+17; + break; + } } + else + { + switch(textHAlign) + { + case AlignLeft: + textPosition.X = 3; + break; + case AlignCentre: + textPosition.X = (Size.X-Graphics::textwidth((char *)ButtonText.c_str()))/2; + break; + case AlignRight: + textPosition.X = (Size.X-Graphics::textwidth((char *)ButtonText.c_str()))-2; + break; + } + } +} + +void Button::SetIcon(Icon icon) +{ + this->icon = icon; + TextPosition(); } void Button::SetText(std::string buttonText) @@ -150,13 +138,15 @@ void Button::Draw(const Point& screenPos) g->drawrect(Position.X, Position.Y, Size.X, Size.Y, 180, 180, 180, 255); g->drawtext(Position.X+textPosition.X, Position.Y+textPosition.Y, ButtonText, 180, 180, 180, 255); } + if(icon) + g->draw_icon(Position.X+3, Position.Y+textPosition.Y, icon); } void Button::OnMouseUp(int x, int y, unsigned int button) { if(button != 1) { - return; //left click only! + return; } if(isButtonDown) @@ -167,16 +157,9 @@ void Button::OnMouseUp(int x, int y, unsigned int button) isButtonDown = false; } -//void Button::OnMouseUp(int x, int y, unsigned int button) //mouse unclick is called before this -//{ - // if(button != 1) return; //left click only! - -// isButtonDown = false; -//} - void Button::OnMouseClick(int x, int y, unsigned int button) { - if(button != 1) return; //left click only! + if(button != 1) return; if(isTogglable) { toggle = !toggle; diff --git a/src/interface/Button.h b/src/interface/Button.h index 1075b322b..4537e1f62 100644 --- a/src/interface/Button.h +++ b/src/interface/Button.h @@ -26,13 +26,10 @@ public: class Button : public Component { public: - Button(Window* parent_state, std::string buttonText); - - Button(Point position, Point size, std::string buttonText); - - Button(std::string buttonText); + Button(Point position = Point(0, 0), Point size = Point(0, 0), std::string buttonText = ""); virtual ~Button(); + Icon icon; bool Toggleable; bool Enabled; @@ -68,6 +65,8 @@ public: void SetActiveBorderColour(Colour border) { this->activeBorder = border; } void SetTextColour(Colour text) { this->text = text; } void SetActiveTextColour(Colour text) { this->activeText = text; } + + void SetIcon(Icon icon); protected: Colour background, activeBackground; Colour border, activeBorder; diff --git a/src/preview/PreviewView.cpp b/src/preview/PreviewView.cpp index 983e730b6..8c69b7bc1 100644 --- a/src/preview/PreviewView.cpp +++ b/src/preview/PreviewView.cpp @@ -32,6 +32,10 @@ PreviewView::PreviewView(): saveNameLabel = new ui::Label(ui::Point(5, (YRES/2)+5), ui::Point(100, 16), ""); saveNameLabel->SetAlignment(AlignLeft, AlignBottom); AddComponent(saveNameLabel); + + authorDateLabel = new ui::Label(ui::Point(5, (YRES/2)+5+16), ui::Point(100, 16), ""); + authorDateLabel->SetAlignment(AlignLeft, AlignBottom); + AddComponent(authorDateLabel); } void PreviewView::OnDraw() diff --git a/src/preview/PreviewView.h b/src/preview/PreviewView.h index ac17df588..e788210e7 100644 --- a/src/preview/PreviewView.h +++ b/src/preview/PreviewView.h @@ -21,6 +21,7 @@ class PreviewView: public ui::Window { Thumbnail * savePreview; ui::Button * openButton; ui::Label * saveNameLabel; + ui::Label * authorDateLabel; public: void AttachController(PreviewController * controller) { c = controller;} PreviewView(); diff --git a/src/render/RenderModel.cpp b/src/render/RenderModel.cpp index 65f4a89c9..52a32acef 100644 --- a/src/render/RenderModel.cpp +++ b/src/render/RenderModel.cpp @@ -7,7 +7,9 @@ #include "RenderModel.h" -RenderModel::RenderModel() { +RenderModel::RenderModel(): + renderer(NULL) +{ // TODO Auto-generated constructor stub }