1 /***************************************************************************
2                 pceditor.h  -  The "recruit character" window
3                              -------------------
4     begin                : Tue Jul 10 2006
5     copyright            : (C) 2006 by Gabor Torok
6     email                : cctorok@yahoo.com
7  ***************************************************************************/
8 
9 /***************************************************************************
10  *                                                                         *
11  *   This program is free software; you can redistribute it and/or modify  *
12  *   it under the terms of the GNU General Public License as published by  *
13  *   the Free Software Foundation; either version 2 of the License, or     *
14  *   (at your option) any later version.                                   *
15  *                                                                         *
16  ***************************************************************************/
17 
18 #ifndef PC_EDITOR_H
19 #define PC_EDITOR_H
20 #pragma once
21 
22 #include "gui/widgetview.h"
23 #include "gui/eventhandler.h"
24 #include "rpg/rpg.h"
25 
26 class Window;
27 class Scourge;
28 class Creature;
29 class CardContainer;
30 class Button;
31 class Widget;
32 class TextField;
33 class ScrollingList;
34 class ScrollingLabel;
35 class Label;
36 class Canvas;
37 class CharacterInfoUI;
38 class Character;
39 
40 /// The window that lets you edit a character's skills before recruiting him/her.
41 class PcEditor : public WidgetView, EventHandler {
42 private:
43 	Window *win;
44 	Scourge *scourge;
45 	Creature *creature;
46 	bool deleteCreature;
47 	CardContainer *cards;
48 	Button *nameButton, *profButton, *statsButton, *deityButton;
49 	Button *imageButton, *okButton, *cancelButton;
50 	TextField *nameField;
51 	Button *nameChangeButton;
52 	ScrollingList *charType;
53 	ScrollingLabel *charTypeDescription;
54 	Label *skillValue[10];
55 	Button *skillPlus[10], *skillMinus[10];
56 	Label *remainingCaptionLabel, *remainingLabel;
57 	CharacterInfoUI *detailsInfo;
58 	Canvas *detailsCanvas;
59 	ScrollingLabel *deityTypeDescription;
60 	ScrollingList *deityType;
61 	Canvas *portrait;
62 	Button *prevPortrait, *nextPortrait;
63 	Button *male, *female;
64 	Canvas *model;
65 	Button *prevModel, *nextModel;
66 	Button *reroll;
67 	std::string* charTypeStr;
68 	std::string* deityTypeStr;
69 	int portraitIndex;
70 	int modelIndex;
71 	int availableSkillMod;
72 
73 	enum {
74 		NAME_TAB = 0,
75 		CLASS_TAB,
76 		STAT_TAB,
77 		DEITY_TAB,
78 		IMAGE_TAB
79 	};
80 
81 public:
82 	PcEditor( Scourge *scourge );
83 	~PcEditor();
84 
getWindow()85 	inline Window *getWindow() {
86 		return win;
87 	}
88 
89 	bool handleEvent( Widget *widget, SDL_Event *event );
90 
91 	virtual void drawWidgetContents( Widget *w );
92 
getOkButton()93 	inline Button *getOkButton() {
94 		return okButton;
95 	}
getCancelButton()96 	inline Button *getCancelButton() {
97 		return cancelButton;
98 	}
99 
100 	void saveUI();
101 	void rollSkills();
102 	void rollSkillsForCreature( Creature *c );
103 	Creature *createPartyMember();
104 
105 	void setCreature( Creature *creature = NULL, bool isEditable = true );
getCreature()106 	inline Creature *getCreature() {
107 		return creature;
108 	}
109 
110 protected:
111 	void deleteLoadedShapes();
112 	void loadUI();
113 	void setCharType( int charIndex );
114 	void setDeityType( int deityIndex );
115 	void createUI();
116 	int getSex();
117 	void rollApperance();
118 };
119 
120 #endif
121 
122