예제 #1
0
LocalSaveActivity::LocalSaveActivity(SaveFile save) :
	WindowActivity(ui::Point(-1, -1), ui::Point(220, 200)),
	thumbnail(NULL),
	save(save)
{
	ui::Label * titleLabel = new ui::Label(ui::Point(4, 5), ui::Point(Size.X-8, 16), "Save to computer:");
	titleLabel->SetTextColour(style::Colour::InformationTitle);
	titleLabel->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
	titleLabel->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
	AddComponent(titleLabel);

	filenameField = new ui::Textbox(ui::Point(8, 25), ui::Point(Size.X-16, 16), save.GetDisplayName(), "[filename]");
	filenameField->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
	filenameField->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
	AddComponent(filenameField);

	ui::Button * cancelButton = new ui::Button(ui::Point(0, Size.Y-16), ui::Point(Size.X-75, 16), "Cancel");
	cancelButton->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
	cancelButton->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
	cancelButton->Appearance.BorderInactive = ui::Colour(200, 200, 200);
	cancelButton->SetActionCallback(new CancelAction(this));
	AddComponent(cancelButton);
	SetCancelButton(cancelButton);

	ui::Button * okayButton = new ui::Button(ui::Point(Size.X-76, Size.Y-16), ui::Point(76, 16), "Save");
	okayButton->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
	okayButton->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
	okayButton->Appearance.TextInactive = style::Colour::InformationTitle;
	okayButton->SetActionCallback(new SaveAction(this));
	AddComponent(okayButton);
	SetOkayButton(okayButton);

	if(save.GetGameSave())
		ThumbnailBroker::Ref().RenderThumbnail(save.GetGameSave(), true, false, Size.X-16, -1, this);
}
예제 #2
0
TagsView::TagsView():
    ui::Window(ui::Point(-1, -1), ui::Point(195, 250))
{

    class CloseAction : public ui::ButtonAction
    {
        TagsView * v;
    public:
        CloseAction(TagsView * _v) {
            v = _v;
        }
        void ActionCallback(ui::Button * sender)
        {
            v->c->Exit();
        }
    };
    closeButton = new ui::Button(ui::Point(0, Size.Y-16), ui::Point(195, 16), "Close");
    closeButton->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
    closeButton->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
    closeButton->SetActionCallback(new CloseAction(this));
    AddComponent(closeButton);
    SetCancelButton(closeButton);


    tagInput = new ui::Textbox(ui::Point(8, Size.Y-40), ui::Point(Size.X-60, 16), "", "[new tag]");
    tagInput->Appearance.icon = IconTag;
    tagInput->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
    tagInput->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
    AddComponent(tagInput);

    class AddTagAction : public ui::ButtonAction
    {
        TagsView * v;
    public:
        AddTagAction(TagsView * _v) {
            v = _v;
        }
        void ActionCallback(ui::Button * sender)
        {
            v->addTag();
        }
    };
    addButton = new ui::Button(ui::Point(tagInput->Position.X+tagInput->Size.X+4, tagInput->Position.Y), ui::Point(40, 16), "Add");
    addButton->Appearance.icon = IconAdd;
    addButton->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
    addButton->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
    addButton->SetActionCallback(new AddTagAction(this));
    AddComponent(addButton);

    if (!Client::Ref().GetAuthUser().ID)
        addButton->Enabled = false;

    title = new ui::Label(ui::Point(5, 5), ui::Point(185, 28), "Manage tags:    \bgTags are only to \nbe used to improve search results");
    title->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
    title->Appearance.VerticalAlign = ui::Appearance::AlignTop;
    title->SetMultiline(true);
    AddComponent(title);
}
예제 #3
0
TextPrompt::TextPrompt(std::string title, std::string message, std::string text, std::string placeholder, bool multiline, TextDialogueCallback * callback_):
	ui::Window(ui::Point(-1, -1), ui::Point(200, 65)),
	callback(callback_)
{
	if(multiline)
		Size.X += 100;

	ui::Label * titleLabel = new ui::Label(ui::Point(4, 5), ui::Point(Size.X-8, 18), title);
	titleLabel->SetTextColour(style::Colour::WarningTitle);
	titleLabel->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
	titleLabel->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
	AddComponent(titleLabel);

	ui::Label * messageLabel = new ui::Label(ui::Point(4, 25), ui::Point(Size.X-8, -1), message);
	messageLabel->SetMultiline(true);
	messageLabel->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
	messageLabel->Appearance.VerticalAlign = ui::Appearance::AlignTop;
	AddComponent(messageLabel);

	Size.Y += messageLabel->Size.Y+4;

	textField = new ui::Textbox(ui::Point(4, messageLabel->Position.Y + messageLabel->Size.Y + 7), ui::Point(Size.X-8, 16), text, placeholder);
	if(multiline)
	{
		textField->SetMultiline(true);
		textField->Size.Y = 60;
		Size.Y += 45;
		textField->Appearance.VerticalAlign = ui::Appearance::AlignTop;
	}
	else
	{
		textField->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
	}
	textField->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
	AddComponent(textField);
	FocusComponent(textField);

	ui::Button * cancelButton = new ui::Button(ui::Point(0, Size.Y-16), ui::Point((Size.X/2)+1, 16), "Cancel");
	cancelButton->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
	cancelButton->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
	cancelButton->Appearance.BorderInactive = ui::Colour(200, 200, 200);
	cancelButton->SetActionCallback(new CloseAction(this, ResultCancel));
	AddComponent(cancelButton);
	SetCancelButton(cancelButton);

	ui::Button * okayButton = new ui::Button(ui::Point(Size.X/2, Size.Y-16), ui::Point(Size.X/2, 16), "Okay");
	okayButton->Appearance.HorizontalAlign = ui::Appearance::AlignRight;
	okayButton->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
	okayButton->Appearance.TextInactive = style::Colour::WarningTitle;
	okayButton->SetActionCallback(new CloseAction(this, ResultOkay));
	AddComponent(okayButton);
	SetOkayButton(okayButton);

	ui::Engine::Ref().ShowWindow(this);
}
예제 #4
0
ConfirmPrompt::ConfirmPrompt(std::string title, std::string message, std::string buttonText, ConfirmDialogueCallback * callback_):
	ui::Window(ui::Point(-1, -1), ui::Point(250, 50)),
	callback(callback_)
{
	int width, height;
	ui::Label * titleLabel = new ui::Label(ui::Point(4, 5), ui::Point(Size.X-8, 15), title);
	titleLabel->SetTextColour(style::Colour::WarningTitle);
	titleLabel->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
	titleLabel->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
	AddComponent(titleLabel);


	ui::Label * messageLabel = new ui::Label(ui::Point(4, 25), ui::Point(Size.X-8, -1), message);
	messageLabel->SetMultiline(true);
	messageLabel->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
	messageLabel->Appearance.VerticalAlign = ui::Appearance::AlignTop;
	AddComponent(messageLabel);

	Size.Y += messageLabel->Size.Y+12;
	Position.Y = (ui::Engine::Ref().GetHeight()-Size.Y)/2;

	class CloseAction: public ui::ButtonAction
	{
	public:
		ConfirmPrompt * prompt;
		DialogueResult result;
		CloseAction(ConfirmPrompt * prompt_, DialogueResult result_) { prompt = prompt_; result = result_; }
		void ActionCallback(ui::Button * sender)
		{
			ui::Engine::Ref().CloseWindow();
			if(prompt->callback)
				prompt->callback->ConfirmCallback(result);
			prompt->SelfDestruct();
		}
	};


	ui::Button * cancelButton = new ui::Button(ui::Point(0, Size.Y-16), ui::Point(Size.X-75, 16), "Cancel");
	cancelButton->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
	cancelButton->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
	cancelButton->Appearance.BorderInactive = ui::Colour(200, 200, 200);
	cancelButton->SetActionCallback(new CloseAction(this, ResultCancel));
	AddComponent(cancelButton);
	SetCancelButton(cancelButton);

	ui::Button * okayButton = new ui::Button(ui::Point(Size.X-76, Size.Y-16), ui::Point(76, 16), buttonText);
	okayButton->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
	okayButton->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
	okayButton->Appearance.TextInactive = style::Colour::WarningTitle;
	okayButton->SetActionCallback(new CloseAction(this, ResultOkay));
	AddComponent(okayButton);
	SetOkayButton(okayButton);

	ui::Engine::Ref().ShowWindow(this);
}
예제 #5
0
void LoadSave::Init(int command, gedString title, gedString confirmButtonText)
{
	SetModal();
	this->command = command;

	Text *text;
	Button *button;		
	int y;	

	text = AddText(title, CENTER_TEXT, 5);
	y = DrawHLine(text->Down() + 2);

	if(command == SAVE_DIALOG)
	{
		SetToolTip(TIP_SAVE);

		text = AddText("File: ", 10, y);
		name = AddEditBox(text->Right(), text->Top(), 200);
		dir = AddListDirectory(name->Right() + 2, y, 80, 0, 0, "select");  dir->SetToolTip(TIP_SAVE_FILE);
		dir->SetSave();
		y = name->Down();
	}
	else if(command == LOAD_DIALOG)
	{
		SetToolTip(TIP_LOAD);

		text = AddText("File: ", 40, y);
		dir = AddListDirectory(text->Right(), y, 200, 0, 0); dir->SetToolTip(TIP_LOAD_FILE);
		y = dir->Down();
	}	
	else if(command == MERGE_DIALOG)
	{
		SetToolTip(TIP_MERGE);

		text = AddText("File: ", 40, y);
		dir = AddListDirectory(text->Right(), y, 200, 0, 0); dir->SetToolTip(TIP_MERGE_FILE);
		y = dir->Down();

		command = LOAD_DIALOG;
	}

	
	//Close
	y = DrawHLine(Height() - 40);

	button = AddButton(confirmButtonText, (WIDTH-135)/2, y, 0, 0, LOADSAVE_OK); SetConfirmButton(button);
	button = AddButton("Cancel", button->Right()+8, y, 0, 0, LOADSAVE_CLOSE); SetCancelButton(button);

	chdir(GameControl::Get()->getGamePath().c_str());
}
예제 #6
0
SaveIDMessage::SaveIDMessage(int id):
	ui::Window(ui::Point((XRES-244)/2, (YRES-90)/2), ui::Point(244, 90))
{
	int textWidth = Graphics::textwidth("Save ID");
	ui::Label * titleLabel = new ui::Label(ui::Point(4, 5), ui::Point(textWidth+20, 16), "Save ID");
	titleLabel->SetTextColour(style::Colour::InformationTitle);
	titleLabel->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
	titleLabel->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
	AddComponent(titleLabel);

	textWidth = Graphics::textwidth("Saved Successfully!");
	ui::Label * messageLabel = new ui::Label(ui::Point(4, 24), ui::Point(textWidth+20, 16), "Saved Successfully!");
	messageLabel->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
	messageLabel->Appearance.VerticalAlign = ui::Appearance::AlignTop;
	AddComponent(messageLabel);

	textWidth = Graphics::textwidth("Click the box below to copy the save ID");
	ui::Label * copyTextLabel = new ui::Label(ui::Point((Size.X-textWidth-20)/2, 35), ui::Point(textWidth+20, 16), "Click the box below to copy the save id");
	copyTextLabel->SetTextColour(ui::Colour(150, 150, 150));
	copyTextLabel->Appearance.HorizontalAlign = ui::Appearance::AlignCentre;
	AddComponent(copyTextLabel);

	textWidth = Graphics::textwidth(format::NumberToString<int>(id).c_str());
	ui::CopyTextButton * copyTextButton = new ui::CopyTextButton(ui::Point((Size.X-textWidth-10)/2, 50), ui::Point(textWidth+10, 18), format::NumberToString<int>(id), copyTextLabel);
	AddComponent(copyTextButton);

	class DismissAction: public ui::ButtonAction
	{
		SaveIDMessage * message;
	public:
		DismissAction(SaveIDMessage * message_) { message = message_; }
		void ActionCallback(ui::Button * sender)
		{
			ui::Engine::Ref().CloseWindow();
			message->SelfDestruct();
		}
	};

	ui::Button * okayButton = new ui::Button(ui::Point(0, Size.Y-16), ui::Point(Size.X, 16), "OK");
	okayButton->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
	okayButton->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
	okayButton->SetActionCallback(new DismissAction(this));
	AddComponent(okayButton);
	SetCancelButton(okayButton);
	
	ui::Engine::Ref().ShowWindow(this);
}
예제 #7
0
ErrorMessage::ErrorMessage(std::string title, std::string message,  ErrorMessageCallback * callback_):
	ui::Window(ui::Point(-1, -1), ui::Point(200, 35)),
	callback(callback_)
{
	ui::Label * titleLabel = new ui::Label(ui::Point(4, 5), ui::Point(Size.X-8, 16), title);
	titleLabel->SetTextColour(style::Colour::ErrorTitle);
	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, -1), message);
	messageLabel->SetMultiline(true);
	messageLabel->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
	messageLabel->Appearance.VerticalAlign = ui::Appearance::AlignTop;
	AddComponent(messageLabel);

	Size.Y += messageLabel->Size.Y+12;
	Position.Y = (ui::Engine::Ref().GetHeight()-Size.Y)/2;

	class DismissAction: public ui::ButtonAction
	{
		ErrorMessage * message;
	public:
		DismissAction(ErrorMessage * message_) { message = message_; }
		void ActionCallback(ui::Button * sender)
		{
			ui::Engine::Ref().CloseWindow();
			if(message->callback)
				message->callback->DismissCallback();
			message->SelfDestruct();
		}
	};

	ui::Button * okayButton = new ui::Button(ui::Point(0, Size.Y-16), ui::Point(Size.X, 16), "Dismiss");
	okayButton->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
	okayButton->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
	okayButton->Appearance.BorderInactive = ui::Colour(200, 200, 200);
	okayButton->SetActionCallback(new DismissAction(this));
	AddComponent(okayButton);
	SetOkayButton(okayButton);
	SetCancelButton(okayButton);
	
	ui::Engine::Ref().ShowWindow(this);
}
예제 #8
0
LoginView::LoginView():
	ui::Window(ui::Point(-1, -1), ui::Point(200, 87)),
	loginButton(new ui::Button(ui::Point(200-100, 87-17), ui::Point(100, 17), "Sign in")),
	cancelButton(new ui::Button(ui::Point(0, 87-17), ui::Point(101, 17), "Cancel")),
	titleLabel(new ui::Label(ui::Point(4, 5), ui::Point(200-16, 16), "Server login")),
	usernameField(new ui::Textbox(ui::Point(8, 25), ui::Point(200-16, 17), Client::Ref().GetAuthUser().Username, "[username]")),
	passwordField(new ui::Textbox(ui::Point(8, 46), ui::Point(200-16, 17), "", "[password]")),
	infoLabel(new ui::Label(ui::Point(8, 67), ui::Point(200-16, 16), "")),
	targetSize(0, 0)
{
	targetSize = Size;
	FocusComponent(usernameField);
	
	infoLabel->Appearance.HorizontalAlign = ui::Appearance::AlignCentre;	infoLabel->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
	infoLabel->Visible = false;
	AddComponent(infoLabel);
	
	AddComponent(loginButton);
	SetOkayButton(loginButton);
	loginButton->Appearance.HorizontalAlign = ui::Appearance::AlignRight;
	loginButton->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
	loginButton->Appearance.TextInactive = style::Colour::ConfirmButton;
	loginButton->SetActionCallback(new LoginAction(this));
	AddComponent(cancelButton);
	SetCancelButton(cancelButton);
	cancelButton->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
	cancelButton->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
	cancelButton->SetActionCallback(new CancelAction(this));
	AddComponent(titleLabel);
	titleLabel->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;	titleLabel->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
	
	AddComponent(usernameField);
	usernameField->Appearance.icon = IconUsername;
	usernameField->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;	usernameField->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
	AddComponent(passwordField);
	passwordField->Appearance.icon = IconPassword;
	passwordField->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;	passwordField->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
	passwordField->SetHidden(true);
}
예제 #9
0
CreateActor::CreateActor(Actor *actor, bool bOnCollision)
	: BaseAction("Create Actor", (GameControl::Get()->Width() - WIDTH)/2, 
				          (GameControl::Get()->Height() - HEIGHT)/2,
						  WIDTH, HEIGHT)
{
	SetModal();
	SetToolTip(TIP_CREATEACTOR);
	this->eventActor = actionActor = actor;

	Text *text;
	Button *button;	
	int y;

	//Title
	text = AddText(CREATE_ACTOR, CENTER_TEXT, 5);
	y = DrawHLine(text->Down() + 2);

	//Body
	text = AddText("    Actor: ", 10, y);
	listActor = AddListPop(text->Right() + 2, text->Top(), 128, 0, LS_ACTOR); listActor->SetToolTip(TIP_CREATEACTOR_ACTOR);

	text = AddText("Animation: ", 10, listActor->Down());
	listAnimation = AddListPop(text->Right() + 2, text->Top(), 128, 0, LS_ANIMATION); listAnimation->SetToolTip(TIP_CREATEACTOR_ANIMATION);

	text = AddText("   Parent: ", 10, listAnimation->Down());
	listParent = AddListPop(text->Right() + 2, text->Top(), 128, 0, LS_PARENT); listParent->SetToolTip(TIP_CREATEACTOR_PARENT);

	text = AddText("     Path: ", 10, listParent->Down());
	listPath = AddListPop(text->Right() + 2, text->Top(), 128, 0, LS_PATH); listPath->SetToolTip(TIP_CREATEACTOR_PATH);

	text = AddText("Initial position: ", 10, listPath->Down() + 4);
	
	text = AddText("x", 10, text->Down());
	posX = AddEditBox(text->Right() + 2, text->Top(), 50); posX->SetNumeric(-650000, 650000, 1);

	text = AddText("y", posX->Right()+5, posX->Top());
	posY = AddEditBox(text->Right() + 4, text->Top(), 50); posY->SetNumeric(-650000, 650000, 1);

	text = AddText("Relative to creator: ", 10, posY->Down() + 2);
	listRelativePos = AddListPop(text->Right() + 2, text->Top(), 40, 0, LS_RELATIVEPOS); listRelativePos->SetToolTip(TIP_CREATEACTOR_RELATIVE);
	
	
	//Close
	y = DrawHLine(listRelativePos->Down() + 2);
	button = AddButton(Action::getEditAction()?"Ok":"Add", (WIDTH-135)/2, y, 0, 0, BT_ADD); button->SetToolTip(TIP_ACTION_ADD); SetConfirmButton(button);
	button = AddButton("Cancel", button->Right()+8, y, 0, 0, BT_CLOSE); button->SetToolTip(TIP_ACTION_CANCEL); SetCancelButton(button);

	posX->SetText(0);
	posY->SetText(0);

	GameControl::Get()->PopulateActors(listActor, false);
	listActor->RemoveText(VIEW_NAME);
	GameControl::Get()->PopulateAnimations(actionActor, listAnimation);
	GameControl::Get()->PopulateActors(listParent);
	listParent->AddText(NO_PARENT);
	listParent->AddText(S_EVENT_ACTOR);	

	if(Tutorial::IsCompatible(VERSION_OUT_OF_VISION_OPTIMIZATION))
	{
		listParent->AddText(S_PARENT_ACTOR);
		listParent->AddText(S_CREATOR_ACTOR);
	}

	if(bOnCollision) listParent->AddText(S_COLLIDE_ACTOR);

	GameControl::Get()->PopulatePaths(listPath);

	if(!Tutorial::IsCompatible(VERSION_OUT_OF_VISION_OPTIMIZATION))
	{
		//Set default only in old tutorials
		listActor->SetItem(actionActor->getActorName());
	}
	else
	{
		//Don't select animations in new version
		listAnimation->RemoveAll();
		listAnimation->SetItem(-1);
	}

	listParent->SetItem(NO_PARENT);
	listPath->SetItem(NO_PATH);

	listRelativePos->AddText("Yes");
	listRelativePos->AddText("No");
	listRelativePos->SetItem("Yes");

	if(!ExpressionEditor::getExpressionEditor()) UpdateEdition();
}
예제 #10
0
ChangeParent::ChangeParent(Actor *actor, bool bOnCollision)
	: BaseAction("Change Parent", (GameControl::Get()->Width() - WIDTH)/2, 
				          (GameControl::Get()->Height() - HEIGHT)/2,
						  WIDTH, HEIGHT)
{
	SetModal();
	SetToolTip(TIP_CHANGEPARENT);
	this->eventActor = actionActor = actor;

	Text *text;
	Button *button;	
	int y;

	//Title
	text = AddText(CHANGE_PARENT, CENTER_TEXT, 5);
	y = DrawHLine(text->Down() + 2);

	//Body
	text = AddText("    Child: ", 10, y);
	listActor = AddListPop(text->Right() + 2, text->Top(), 128, 0, LS_ACTOR);  listActor->SetToolTip(gedString(TIP_CHANGEPARENT_CHILD) + TIP_ACTION_ACTOR);
	text = AddText("   Parent: ", 10, listActor->Down());
	listParent = AddListPop(text->Right() + 2, text->Top(), 128, 0, LS_PARENT); listParent->SetToolTip(TIP_CHANGEPARENT_PARENT);
	
	
	//Close
	y = DrawHLine(listParent->Down() + 2);
	button = AddButton(Action::getEditAction()?"Ok":"Add", 45, y, 0, 0, BT_ADD); button->SetToolTip(TIP_ACTION_ADD); SetConfirmButton(button);
	button = AddButton("Cancel", button->Right()+8, y, 0, 0, BT_CLOSE); button->SetToolTip(TIP_ACTION_CANCEL); SetCancelButton(button);	


	GameControl::Get()->PopulateActors(listParent);
	listParent->AddText(NO_PARENT);
	if(actionActor && actionActor->getParent())
	{
		listParent->SetItem(actionActor->getCloneName());
	}
	else
	{
		listParent->SetItem(NO_PARENT);
	}
	
	GameControl::Get()->PopulateActors(listActor);
	
	listActor->AddText(S_EVENT_ACTOR);
	listParent->AddText(S_EVENT_ACTOR);

	if(Tutorial::IsCompatible(VERSION_OUT_OF_VISION_OPTIMIZATION))
	{
		listActor->AddText(S_PARENT_ACTOR);
		listActor->AddText(S_CREATOR_ACTOR);

		listParent->AddText(S_PARENT_ACTOR);
		listParent->AddText(S_CREATOR_ACTOR);
	}

	if(bOnCollision) listParent->AddText(S_COLLIDE_ACTOR);
	if(bOnCollision) listActor->AddText(S_COLLIDE_ACTOR);

	listActor->SetItem(S_EVENT_ACTOR);

	if(!ExpressionEditor::getExpressionEditor()) UpdateEdition();
}
예제 #11
0
ToMousePosition::ToMousePosition(Actor *actor, bool bOnCollision)
	: BaseAction("To Mouse Position", (GameControl::Get()->Width() - WIDTH)/2, 
				          (GameControl::Get()->Height() - HEIGHT)/2,
						  WIDTH, HEIGHT)
{
	SetModal();
	SetToolTip(TIP_FOLLOW_MOUSE);
	this->eventActor = actionActor = actor;

	Text *text;
	Button *button;	
	int y;

	//Title
	text = AddText(FOLLOW_MOUSE, CENTER_TEXT, 5);
	y = DrawHLine(text->Down() + 2);

	//Body
	text = AddText("Actor: ", 10, y);
	listActor = AddListPop(text->Right() + 2, text->Top(), 128, 0, LS_ACTOR); listActor->SetToolTip(gedString(TIP_FOLLOW_MOUSE_ACTOR) + TIP_ACTION_ACTOR);
	text = AddText(" Axis: ", 10, listActor->Down());
	listAxis = AddListPop(text->Right() + 2, text->Top(), 128); listAxis->SetToolTip(TIP_FOLLOW_MOUSE_AXIS);
	
	
	//Close
	y = DrawHLine(listAxis->Down() + 2);
	button = AddButton(Action::getEditAction()?"Ok":"Add", 45, y, 0, 0, BT_ADD); button->SetToolTip(TIP_ACTION_ADD); SetConfirmButton(button);
	button = AddButton("Cancel", button->Right()+8, y, 0, 0, BT_CLOSE); button->SetToolTip(TIP_ACTION_CANCEL); SetCancelButton(button);


	GameControl::Get()->PopulateActors(listActor);
	listActor->AddText(S_EVENT_ACTOR);

	if(Tutorial::IsCompatible(VERSION_OUT_OF_VISION_OPTIMIZATION))
	{
		listActor->AddText(S_PARENT_ACTOR);
		listActor->AddText(S_CREATOR_ACTOR);
	}

	if(bOnCollision) listActor->AddText(S_COLLIDE_ACTOR);
	listActor->SetItem(S_EVENT_ACTOR);


	listAxis->AddText("Both");
	listAxis->AddText("x");
	listAxis->AddText("y");
	listAxis->AddText("none");
	listAxis->SetItem("Both");

	if(!ExpressionEditor::getExpressionEditor()) UpdateEdition();
}
예제 #12
0
OptionsView::OptionsView():
	ui::Window(ui::Point(-1, -1), ui::Point(300, 310)){

	ui::Label * tempLabel = new ui::Label(ui::Point(4, 5), ui::Point(Size.X-8, 14), "Simulation Options");
	tempLabel->SetTextColour(style::Colour::InformationTitle);
	tempLabel->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;	tempLabel->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
	AddComponent(tempLabel);

	class HeatSimulationAction: public ui::CheckboxAction
	{
		OptionsView * v;
	public:
		HeatSimulationAction(OptionsView * v_){	v = v_;	}
		virtual void ActionCallback(ui::Checkbox * sender){	v->c->SetHeatSimulation(sender->GetChecked()); }
	};

	heatSimulation = new ui::Checkbox(ui::Point(8, 23), ui::Point(Size.X-6, 16), "Heat simulation \bgIntroduced in version 34", "");
	heatSimulation->SetActionCallback(new HeatSimulationAction(this));
	AddComponent(heatSimulation);
	tempLabel = new ui::Label(ui::Point(24, heatSimulation->Position.Y+14), ui::Point(Size.X-28, 16), "\bgCan cause odd behaviour with very old saves");
	tempLabel->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;	tempLabel->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
	AddComponent(tempLabel);

	class AmbientHeatSimulationAction: public ui::CheckboxAction
	{
		OptionsView * v;
	public:
		AmbientHeatSimulationAction(OptionsView * v_){	v = v_;	}
		virtual void ActionCallback(ui::Checkbox * sender){	v->c->SetAmbientHeatSimulation(sender->GetChecked()); }
	};

	ambientHeatSimulation = new ui::Checkbox(ui::Point(8, 53), ui::Point(Size.X-6, 16), "Ambient heat simulation \bgIntroduced in version 50", "");
	ambientHeatSimulation->SetActionCallback(new AmbientHeatSimulationAction(this));
	AddComponent(ambientHeatSimulation);
	tempLabel = new ui::Label(ui::Point(24, ambientHeatSimulation->Position.Y+14), ui::Point(Size.X-28, 16), "\bgCan cause odd behaviour with old saves");
	tempLabel->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;	tempLabel->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
	AddComponent(tempLabel);

	class NewtonianGravityAction: public ui::CheckboxAction
	{
		OptionsView * v;
	public:
		NewtonianGravityAction(OptionsView * v_){	v = v_;	}
		virtual void ActionCallback(ui::Checkbox * sender){	v->c->SetNewtonianGravity(sender->GetChecked()); }
	};

	newtonianGravity = new ui::Checkbox(ui::Point(8, 83), ui::Point(Size.X-6, 16), "Newtonian gravity \bgIntroduced in version 48", "");
	newtonianGravity->SetActionCallback(new NewtonianGravityAction(this));
	AddComponent(newtonianGravity);
	tempLabel = new ui::Label(ui::Point(24, newtonianGravity->Position.Y+14), ui::Point(Size.X-28, 16), "\bgMay cause poor performance on older computers");
	tempLabel->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;	tempLabel->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
	AddComponent(tempLabel);

	class WaterEqualisationAction: public ui::CheckboxAction
		{
			OptionsView * v;
		public:
			WaterEqualisationAction(OptionsView * v_){	v = v_;	}
			virtual void ActionCallback(ui::Checkbox * sender){	v->c->SetWaterEqualisation(sender->GetChecked()); }
		};

	waterEqualisation = new ui::Checkbox(ui::Point(8, 113), ui::Point(Size.X-6, 16), "Water equalisation \bgIntroduced in version 61", "");
	waterEqualisation->SetActionCallback(new WaterEqualisationAction(this));
	AddComponent(waterEqualisation);
	tempLabel = new ui::Label(ui::Point(24, waterEqualisation->Position.Y+14), ui::Point(Size.X-28, 16), "\bgMay cause poor performance with a lot of water");
	tempLabel->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;	tempLabel->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
	AddComponent(tempLabel);

	class AirModeChanged: public ui::DropDownAction
	{
		OptionsView * v;
	public:
		AirModeChanged(OptionsView * v): v(v) { }
		virtual void OptionChanged(ui::DropDown * sender, std::pair<std::string, int> option) { v->c->SetAirMode(option.second); }
	};
	airMode = new ui::DropDown(ui::Point(Size.X-88, 146), ui::Point(80, 16));
	AddComponent(airMode);
	airMode->AddOption(std::pair<std::string, int>("On", 0));
	airMode->AddOption(std::pair<std::string, int>("Pressure off", 1));
	airMode->AddOption(std::pair<std::string, int>("Velocity off", 2));
	airMode->AddOption(std::pair<std::string, int>("Off", 3));
	airMode->AddOption(std::pair<std::string, int>("No Update", 4));
	airMode->SetActionCallback(new AirModeChanged(this));
		
	tempLabel = new ui::Label(ui::Point(8, 146), ui::Point(Size.X-96, 16), "Air Simulation Mode");
	tempLabel->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;	tempLabel->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
	AddComponent(tempLabel);
		
	class GravityModeChanged: public ui::DropDownAction
	{
		OptionsView * v;
	public:
		GravityModeChanged(OptionsView * v): v(v) { }
		virtual void OptionChanged(ui::DropDown * sender, std::pair<std::string, int> option) { v->c->SetGravityMode(option.second); }
	};	
		
	gravityMode = new ui::DropDown(ui::Point(Size.X-88, 166), ui::Point(80, 16));
	AddComponent(gravityMode);
	gravityMode->AddOption(std::pair<std::string, int>("Vertical", 0));
	gravityMode->AddOption(std::pair<std::string, int>("Off", 1));
	gravityMode->AddOption(std::pair<std::string, int>("Radial", 2));
	gravityMode->SetActionCallback(new GravityModeChanged(this));

	tempLabel = new ui::Label(ui::Point(8, 166), ui::Point(Size.X-96, 16), "Gravity Simulation Mode");
	tempLabel->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;	tempLabel->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
	AddComponent(tempLabel);

	class EdgeModeChanged: public ui::DropDownAction
	{
		OptionsView * v;
	public:
		EdgeModeChanged(OptionsView * v): v(v) { }
		virtual void OptionChanged(ui::DropDown * sender, std::pair<std::string, int> option) { v->c->SetEdgeMode(option.second); }
	};	

	edgeMode = new ui::DropDown(ui::Point(Size.X-88, 186), ui::Point(80, 16));
	AddComponent(edgeMode);
	edgeMode->AddOption(std::pair<std::string, int>("Void", 0));
	edgeMode->AddOption(std::pair<std::string, int>("Solid", 1));
	edgeMode->SetActionCallback(new EdgeModeChanged(this));

	tempLabel = new ui::Label(ui::Point(8, 186), ui::Point(Size.X-96, 16), "Edge Mode");
	tempLabel->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;	tempLabel->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
	AddComponent(tempLabel);

	class ScaleAction: public ui::CheckboxAction
	{
		OptionsView * v;
	public:
		ScaleAction(OptionsView * v_){	v = v_;	}
		virtual void ActionCallback(ui::Checkbox * sender){	v->c->SetScale(sender->GetChecked()); }
	};

	scale = new ui::Checkbox(ui::Point(8, 210), ui::Point(Size.X-6, 16), "Large screen", "");
	scale->SetActionCallback(new ScaleAction(this));
	tempLabel = new ui::Label(ui::Point(scale->Position.X+Graphics::textwidth(scale->GetText().c_str())+20, scale->Position.Y), ui::Point(Size.X-28, 16), "\bg- Double window size for smaller screen");
	tempLabel->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;	tempLabel->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
	AddComponent(tempLabel);
	AddComponent(scale);


	class FullscreenAction: public ui::CheckboxAction
	{
		OptionsView * v;
	public:
		FullscreenAction(OptionsView * v_){	v = v_;	}
		virtual void ActionCallback(ui::Checkbox * sender){	v->c->SetFullscreen(sender->GetChecked()); }
	};

	fullscreen = new ui::Checkbox(ui::Point(8, 230), ui::Point(Size.X-6, 16), "Fullscreen", "");
	fullscreen->SetActionCallback(new FullscreenAction(this));
	tempLabel = new ui::Label(ui::Point(fullscreen->Position.X+Graphics::textwidth(fullscreen->GetText().c_str())+20, fullscreen->Position.Y), ui::Point(Size.X-28, 16), "\bg- Use the entire screen");
	tempLabel->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;	tempLabel->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
	AddComponent(tempLabel);
	AddComponent(fullscreen);


	class FastQuitAction: public ui::CheckboxAction
	{
		OptionsView * v;
	public:
		FastQuitAction(OptionsView * v_){	v = v_;	}
		virtual void ActionCallback(ui::Checkbox * sender){	v->c->SetFastQuit(sender->GetChecked()); }
	};

	fastquit = new ui::Checkbox(ui::Point(8, 250), ui::Point(Size.X-6, 16), "Fast Quit", "");
	fastquit->SetActionCallback(new FastQuitAction(this));
	tempLabel = new ui::Label(ui::Point(fastquit->Position.X+Graphics::textwidth(fastquit->GetText().c_str())+20, fastquit->Position.Y), ui::Point(Size.X-28, 16), "\bg- Always exit completely when hitting close");
	tempLabel->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;	tempLabel->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
	AddComponent(tempLabel);
	AddComponent(fastquit);

	class ShowAvatarsAction: public ui::CheckboxAction
	{
		OptionsView * v;
	public:
		ShowAvatarsAction(OptionsView * v_){	v = v_;	}
		virtual void ActionCallback(ui::Checkbox * sender){	v->c->SetShowAvatars(sender->GetChecked()); }
	};

	showAvatars = new ui::Checkbox(ui::Point(8, 270), ui::Point(Size.X-6, 16), "Show Avatars", "");
	showAvatars->SetActionCallback(new ShowAvatarsAction(this));
	tempLabel = new ui::Label(ui::Point(showAvatars->Position.X+Graphics::textwidth(showAvatars->GetText().c_str())+20, showAvatars->Position.Y), ui::Point(Size.X-28, 16), "\bg- Disable if you have a slow connection");
	tempLabel->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;	tempLabel->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
	AddComponent(tempLabel);
	AddComponent(showAvatars);

	class CloseAction: public ui::ButtonAction
	{
	public:
		OptionsView * v;
		CloseAction(OptionsView * v_) { v = v_; }
		void ActionCallback(ui::Button * sender)
		{
			v->c->Exit();
		}
	};

	ui::Button * tempButton = new ui::Button(ui::Point(0, Size.Y-16), ui::Point(Size.X, 16), "OK");
	tempButton->SetActionCallback(new CloseAction(this));
	AddComponent(tempButton);
	SetCancelButton(tempButton);
	SetOkayButton(tempButton);
}
예제 #13
0
GameSettings::GameSettings()
	: Panel("GameSettings", (GameControl::Get()->Width() - WIDTH)/2, 
	(GameControl::Get()->Height() - getHeight())/2,
						  WIDTH, getHeight())
{
	SetModal();
	SetToolTip(TIP_GAMESETTINGS);

	gameSettings = this;
	listSuspend = listESC = listMotion = NULL;
	editViewSafeMargin = NULL;
	gamePort = gameID = NULL;
	listAutoStartNetwork = listGameServer = NULL;

	Text *text;
	Button *button;	
	int y, editSize = 40, editStart = 22;

	if(!Tutorial::IsCompatible(VERSION_OUT_OF_VISION_OPTIMIZATION))
	{
		editSize = 45;
		editStart = 8;
	}

	//Title
	text = AddText("Game Properties", CENTER_TEXT, 5);
	y = DrawHLine(text->Down() + 2);

	//Body
	text = AddText("Game resolution: ", 10, y);
	listRes = AddListPop(text->Right(), text->Top(), 128, 0, LS_RES); listRes->SetToolTip(TIP_GAMESETTINGS_RESOLUTION);

	editX = AddEditBox(listRes->Right() + editStart, listRes->Top(), editSize); editX->SetNumeric(2, 2000, 1);
	text = AddText("x", editX->Right()+1, editX->Top());
	editY = AddEditBox(text->Right() + 4, text->Top(), editSize); editY->SetNumeric(2, 2000, 1);

	text = AddText("Mode:            ", 10, editY->Down() + 4);
	listFull = AddListPop(text->Right(), text->Top(), 128, 0, LS_FULL); listFull->SetToolTip(TIP_GAMESETTINGS_MODE);

	if(Tutorial::IsCompatible(VERSION_OUT_OF_VISION_OPTIMIZATION))
	{
		text = AddText(" Safe margin: ", listFull->Right(), listFull->Top());
		editViewSafeMargin = AddEditBox(editY->Left(), text->Top(), editSize); editViewSafeMargin->SetNumeric(0, 2000, 1);
	}

	text = AddText("Frame rate:      ", 10, listFull->Down() + 4);
	editFps = AddEditBox(text->Right(), text->Top(), 50); editFps->SetNumeric(1, 512, 1);
	text = AddText("fps", editFps->Right() + 2, editFps->Top());

	listMouse = AddListPop(text->Right() + 32, text->Top(), 128, 0, LS_MOUSE); listMouse->SetToolTip(TIP_GAMESETTINGS_MOUSE);

	if(Tutorial::IsCompatible(VERSION_OUT_OF_VISION_OPTIMIZATION))
	{
		text = AddText("Suspend game if lost focus: ", 10, editFps->Down() + 6);
		listSuspend = AddListPop(text->Right() + 48, text->Top(), 32, 0, LS_SUSPEND); listSuspend->SetToolTip(TIP_GAMESETTINGS_SUSPEND);

		if(Tutorial::IsCompatible(VERSION_ESC_TO_EXIT))
		{
			text = AddText("  Use ESC key to exit game: ", 10, listSuspend->Down() + 6);
			listESC = AddListPop(text->Right() + 48, text->Top(), 32, 0, LS_ESC); listESC->SetToolTip(TIP_GAMESETTINGS_ESC);

			text = AddText("       Motion Compensation: ", 10, listESC->Down() + 6);
			listMotion = AddListPop(text->Right() + 48, text->Top(), 32, 0, LS_MOTION); listMotion->SetToolTip(TIP_GAMESETTINGS_MOTION_COMPENSATION);
		}
		
		
		y = DrawHLine(text->Down() + 8);
	}
	else
	{
		y = DrawHLine(editFps->Down() + 4);
	}
	
	text = AddText("Audio format: ", 10, y);
	listHz = AddListPop(text->Right(), text->Top(), 128, 0, LS_HZ); listHz->SetToolTip(TIP_GAMESETTINGS_AUDIO_HZ);
	listStereo = AddListPop(listHz->Right() + 4, listHz->Top(), 128, 0, LS_STEREO); listStereo->SetToolTip(TIP_GAMESETTINGS_AUDIO_STEREO);
	text = AddText("Maximum number of simultaneous sounds: ", 10, listStereo->Down()+4);
	editMaxSounds = AddEditBox(text->Right(), text->Top(), 50); editMaxSounds->SetNumeric(1, 512, 1);
	
	y = DrawHLine(editMaxSounds->Down() + 2);

	text = AddText("            Icon file:  ", 10, y + 2);
	iconPath = AddListDirectory(text->Right(), text->Top()); iconPath->SetToolTip(TIP_GAMESETTINGS_ICON);

	text = AddText("           Game title: ", 10, iconPath->Down() + 4);
	gameTitle = AddEditBox(text->Right(), text->Top(), 150);

	text = AddText("Game background color: ", 10, gameTitle->Down() + 4);
	backgroundColor = new ColorSample(this, text->Right(), text->Top(), 32); backgroundColor->SetToolTip(TIP_GAMESETTINGS_BACKGROUNDCOLOR);

	//Network
	if(Tutorial::IsCompatible(VERSION_NETWORK) && GAME_EDITOR_VERSION >= VERSION_NETWORK)
	{
		y = DrawHLine(backgroundColor->Down() + 2);

		text = AddText("     Game ID: ", 10, y);		
		gameID = AddEditBox(text->Right(), text->Top(), 256);

		text = AddText("Network Port: ", 10, gameID->Down() + 4);		
		gamePort = AddEditBox(text->Right(), text->Top(), 64);

		text = AddText("Use Game Editor Server: ", 10, gamePort->Down() + 4);
		listGameServer = AddListPop(text->Right() + 2, text->Top(), 32, 0, LS_GAMESERVER); listGameServer->SetToolTip(TIP_GAMESETTINGS_GAME_SERVER);

		text = AddText("    Auto Start Network: ", 10, listGameServer->Down() + 4);
		listAutoStartNetwork = AddListPop(text->Right() + 2, text->Top(), 32, 0, LS_AUTOSTART_NETWORK); listAutoStartNetwork->SetToolTip(TIP_GAMESETTINGS_AUTO_START_NETWORK);

		y = listAutoStartNetwork->Down() + 2;
	}
	else
	{
		y = backgroundColor->Down() + 2;
	}

	//PocketPC
	y = DrawHLine(y);
	listPocketKeys = AddListPop(10, y, 256, 0, LS_POCKET_KEYS, "Pocket PC and GP2X Keys"); listPocketKeys->SetToolTip(TIP_GAMESETTINGS_POCKET_KEYS);
	
	//Close
	y = DrawHLine(listPocketKeys->Down() + 2);
	button = AddButton("Ok", Width()/2 - 70, y, 0, 0, BT_ADD); SetConfirmButton(button);
	button = AddButton("Cancel", button->Right()+8, y, 0, 0, BT_CLOSE); SetCancelButton(button);


	//Populate resolutions
	char buf[64];
	if(Tutorial::IsOff())
	{
		SDL_Rect **modes;
		const SDL_VideoInfo *vinfo = SDL_GetVideoInfo();
		
		/* Get available fullscreen/hardware modes */
		modes=SDL_ListModes(vinfo->vfmt, VIDEO_FLAGS | SDL_FULLSCREEN);
		
		if(modes != (SDL_Rect **)0 && modes != (SDL_Rect **)-1)
		{		
			for(int i=0;modes[i];++i)
			{
				sprintf(buf, "%d x %d", modes[i]->w, modes[i]->h);
				listRes->AddText(buf);
			}
		}
	}
	else
	{
		//Don't change in different machines
		listRes->AddText("1280 x 1024");
		listRes->AddText("1280 x 960");
		listRes->AddText("1280 x 768");
		listRes->AddText("1280 x 720");
		listRes->AddText("1152 x 864");
		listRes->AddText("1024 x 768");
		listRes->AddText("848 x 480");
		listRes->AddText("800 x 600");
		listRes->AddText("720 x 576");
		listRes->AddText("720 x 480");
		listRes->AddText("640 x 480");
		listRes->AddText("640 x 400");
		listRes->AddText("512 x 384");
		listRes->AddText("480 x 360");
		listRes->AddText("400 x 300");
		listRes->AddText("320 x 240");
		listRes->AddText("320 x 200");		
	}

	if(Tutorial::IsCompatible(VERSION_OUT_OF_VISION_OPTIMIZATION))
	{
		listRes->AddText("240 x 320");
		listRes->AddText("240 x 320 Pocket PC");
		listRes->AddText("240 x 320 Pocket PC Upside down");
		listRes->AddText("320 x 240 Pocket PC Rotate left");
		listRes->AddText("320 x 240 Pocket PC Rotate right");

		listRes->AddText("480 x 640 Pocket PC");
		listRes->AddText("480 x 640 Pocket PC Upside down");
		listRes->AddText("640 x 480 Pocket PC Rotate left");
		listRes->AddText("640 x 480 Pocket PC Rotate right");
		listRes->AddText("800 x 480 Pocket PC Rotate left");
		listRes->AddText("800 x 480 Pocket PC Rotate right");

		//No changes in screen orientation now (don't have the w > h information)
		listRes->AddText("240 x 240 Pocket PC");
		listRes->AddText("480 x 480 Pocket PC");

		//Smartphone
		listRes->AddText("176 x 220 Smartphone");
		listRes->AddText("160 x 240 Smartphone");
		listRes->AddText("208 x 240 Smartphone");
		listRes->AddText("240 x 320 Smartphone");

		//HPC
		listRes->AddText("640 x 240 Handheld PC");
		listRes->AddText("640 x 480 Handheld PC");
		listRes->AddText("800 x 480 Handheld PC");
		listRes->AddText("800 x 600 Handheld PC");

		//GP2X
		listRes->AddText("320 x 240 GP2X");
		listRes->AddText("640 x 480 GP2X");

		// Apple iPhone // AKR
		listRes->AddText("320 x 480 iPhone");
		listRes->AddText("480 x 320 iPhone Rotate left");

		// Apple iPad // AKR
		listRes->AddText("768 x 1024 iPad");
		listRes->AddText("1024 x 768 iPad Rotate left");

	}
	else
	{
		listRes->AddText("240 x 320 Pocket PC");
	}

	listFull->AddText("Full screen");
	listFull->AddText("Window");


	listHz->AddText("44100 Hz");
	listHz->AddText("22050 Hz");
	listHz->AddText("11025 Hz");


	listStereo->AddText("Stereo");
	listStereo->AddText("Mono");

	listMouse->AddText("Show mouse");
	listMouse->AddText("Hide mouse");

	if(listSuspend)
	{
		listSuspend->AddText("Yes");
		listSuspend->AddText("No");
		
		if(GameControl::Get()->getSuspendGameIfLostFocus()) listSuspend->SetItem("Yes");
		else listSuspend->SetItem("No");
	}

	if(listAutoStartNetwork)
	{
		listAutoStartNetwork->AddText("Yes");
		listAutoStartNetwork->AddText("No");
				
		if(GameControl::Get()->getAutoStartNetwork()) listAutoStartNetwork->SetItem("Yes");
		else listAutoStartNetwork->SetItem("No");
	}

	if(listGameServer)
	{
		listGameServer->AddText("Yes");
		listGameServer->AddText("No");
				
		if(GameControl::Get()->getUseGameEditorServer()) listGameServer->SetItem("Yes");
		else listGameServer->SetItem("No");
	}

	if(listESC)
	{
		listESC->AddText("Yes");
		listESC->AddText("No");
		
		if(GameControl::Get()->getUseESCKeyToExit()) listESC->SetItem("Yes");
		else listESC->SetItem("No");
	}

	if(listMotion)
	{
		listMotion->AddText("Yes");
		listMotion->AddText("No");
		
		if(GameControl::Get()->getUseMotionCorrection()) listMotion->SetItem("Yes");
		else listMotion->SetItem("No");
	}

	if(gameID)
	{		
		gameID->SetText(GameControl::Get()->getGameID());
	}

	if(gamePort)
	{		
		gamePort->SetText(GameControl::Get()->getGamePort());
	}


	if(GameControl::Get()->getFullScreen()) listFull->SetItem("Full screen");
	else listFull->SetItem("Window");

	if(GameControl::Get()->getStereo()) listStereo->SetItem("Stereo");
	else listStereo->SetItem("Mono");

	if(GameControl::Get()->getShowMouse()) listMouse->SetItem("Show mouse");
	else listMouse->SetItem("Hide mouse");

	if(editViewSafeMargin)
	{
		editViewSafeMargin->SetText((int)GameControl::Get()->getViewSafeMargin());
	}
	

	sprintf(buf, "%ld Hz", GameControl::Get()->getAudioSamplerRate()); 
	listHz->SetItem(buf);

	sprintf(buf, "%d x %d", GameControl::Get()->getGameWidth(), GameControl::Get()->getGameHeight());
	listRes->SetItem(buf);

	editX->SetText(GameControl::Get()->getGameWidth());
	editY->SetText(GameControl::Get()->getGameHeight());
	editFps->SetText(GameControl::Get()->getFrameRate());
	editMaxSounds->SetText(GameControl::Get()->getMaximumSounds());

	bFlipPocketPCScreen = GameControl::Get()->getFlipPocketPCScreen();

	gedString res(buf);
	if(res == "240 x 320")
	{
		if(bFlipPocketPCScreen)
		{
			listRes->SetText("240 x 320 Up. down");
		}
	}
	else if(res == "320 x 240")
	{
		if(bFlipPocketPCScreen)
		{
			listRes->SetText("320 x 240 Rot.right");
		}
		else
		{
			listRes->SetText("320 x 240 Rot. left");
		}
	}
	else if(res == "480 x 640")
	{
		if(bFlipPocketPCScreen)
		{
			listRes->SetText("480 x 640 Up. down");
		}
		else
		{
			listRes->SetText("480 x 640 Pocket PC");
		}
	}
	else if(res == "640 x 480")
	{
		if(bFlipPocketPCScreen)
		{
			listRes->SetText("640 x 480 Rot.right");
		}
		else
		{
			//listRes->SetText("640 x 480 Rot. left");
			listRes->SetText("640 x 480");
		}
	}
	else if(res == "320 x 480")
	{
			listRes->SetText("320 x 480 iPhone");
	}
	else if(res == "480 x 320")
	{
		listRes->SetText("480 x 320 Rot.left");
	}
	else if(res == "768 x 1024")
	{
			listRes->SetText("768x1024 iPad");
	}
	else if(res == "800 x 480")
	{
		if(bFlipPocketPCScreen)
		{
			listRes->SetText("800 x 480 Rot.right");
		}
		else
		{			
			listRes->SetText("800 x 480");
		}
	}
	else if(res == "240 x 240")
	{
		listRes->SetText("240 x 240 Pocket PC");
	}
	else if(res == "480 x 480")
	{
		listRes->SetText("480 x 480 Pocket PC");
	}
	else if(res == "176 x 220")
	{
		listRes->SetText("176 x 220 Smartphone");
	}
	else if(res == "160 x 240")
	{
		listRes->SetText("160 x 240 Smartphone");
	}
	else if(res == "208 x 240")
	{
		listRes->SetText("208 x 240 Smartphone");
	}



	iconPath->AddFilter("tga");
	iconPath->AddFilter("bmp");
	iconPath->AddFilter("pnm");
	iconPath->AddFilter("xpm");
	iconPath->AddFilter("xcf");
	iconPath->AddFilter("pcx");
	iconPath->AddFilter("gif");
	iconPath->AddFilter("jpg");
	iconPath->AddFilter("jpeg");
	iconPath->AddFilter("jpe");
	iconPath->AddFilter("jfif");
	iconPath->AddFilter("tif");
	iconPath->AddFilter("tiff");
	iconPath->AddFilter("iff");
	iconPath->AddFilter("lbm");
	iconPath->AddFilter("png");
	iconPath->AddFilter("ico");

	//iconPath->SetText(GameControl::Get()->getIconPath());

	if(!GameControl::Get()->getIconPath().empty())
	{
		gedString file, dir;
		SplitPath(GameControl::Get()->getIconPath(), file, dir);
		chdir(dir.c_str());

		iconPath->AddText(file);
		iconPath->SetItem(file);
	}

	gameTitle->SetText(GameControl::Get()->getGameTitle());

	backgroundColor->setColor(GameControl::Get()->getBackGroundColor());

	SetPocketKeys();
}
예제 #14
0
ColorPicker::ColorPicker(int _r, int _g, int _b)
	: Panel("DlgColorPicker", (GameControl::Get()->Width() - WIDTH)/2, 
				          (GameControl::Get()->Height() - HEIGHT)/2,
						  WIDTH, HEIGHT)
{
	SetModal();

	Text *text;
	Button *button;

	//Title
	text = AddText("Color Picker", CENTER_TEXT, 5);
	int y = DrawHLine(text->Down() + 2);

	//Body
	canvas = new ColorCanvas(this);
	oldColor = new ColorSampleOfPicker(this);
	newColor = new ColorSampleOfPicker(this);

	canvas->SetPos(10, y + 2);	
	
	

	colorSlide = AddSlide(canvas->Right() + 5, canvas->Top(), 20, 256, SL_COLOR);
	colorSlide->SetPos(1.0);


	newColor->SetPos(colorSlide->Right() + 5, colorSlide->Top());
	oldColor->SetPos(newColor->Left(), newColor->Down());

	text = AddText("       Red: ", oldColor->Left(), oldColor->Down() + 16);
	rEdit = AddEditBox(text->Right(), text->Top(), 32); rEdit->SetNumeric(0, 255, 1);

	text = AddText("     Green: ", text->Left(), rEdit->Down() + 2);
	gEdit = AddEditBox(text->Right(), text->Top(), 32); gEdit->SetNumeric(0, 255, 1);

	text = AddText("      Blue: ", text->Left(), gEdit->Down() + 2);
	bEdit = AddEditBox(text->Right(), text->Top(), 32); bEdit->SetNumeric(0, 255, 1);


	text = AddText("       Hue: ", text->Left(), bEdit->Down() + 16);
	hEdit = AddEditBox(text->Right(), text->Top(), 32); hEdit->SetNumeric(0, 359, 1);

	text = AddText("Saturation: ", text->Left(), hEdit->Down() + 2);
	sEdit = AddEditBox(text->Right(), text->Top(), 32); sEdit->SetNumeric(0, 100, 1);

	text = AddText("Brightness: ", text->Left(), sEdit->Down() + 2);
	vEdit = AddEditBox(text->Right(), text->Top(), 32); vEdit->SetNumeric(0, 100, 1);

	listFix = AddListPop(oldColor->Left(), vEdit->Down() + 16, 104, 0, LS_FIX_COLOR);

	//Close
	y = DrawHLine(canvas->Down() + 2);

	button = AddButton("Ok", (WIDTH-135)/2, y, 0, 0, OK_BUTTON); SetConfirmButton(button);
	button = AddButton("Cancel", button->Right()+8, y, 0, 0, CANCEL_BUTTON); SetCancelButton(button);

	

	listFix->AddText("Red");
	listFix->AddText("Green");
	listFix->AddText("Blue");

	listFix->AddText("Hue");
	listFix->AddText("Saturation");
	listFix->AddText("Brightness");

	listFix->SetText("Red");	
	fixedColor = FIX_RED;
	r = _r;
	g = _g;
	b = _b;
	
	oldColor->SetColor(r, g, b);
	

	colorSlide->SetPos(r / 255.0);

	UpdateSample(r, g, b);	
	UpdateCanvas(r, fixedColor);
	UpdateSlideColor(r, g, b, fixedColor);
}
예제 #15
0
OptionsView::OptionsView():
    ui::Window(ui::Point(-1, -1), ui::Point(300, 330)) {

    ui::Label * tempLabel = new ui::Label(ui::Point(4, 5), ui::Point(Size.X-8, 14), "Simulation Options");
    tempLabel->SetTextColour(style::Colour::InformationTitle);
    tempLabel->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
    tempLabel->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
    AddComponent(tempLabel);

    class HeatSimulationAction: public ui::CheckboxAction
    {
        OptionsView * v;
    public:
        HeatSimulationAction(OptionsView * v_) {
            v = v_;
        }
        virtual void ActionCallback(ui::Checkbox * sender) {
            v->c->SetHeatSimulation(sender->GetChecked());
        }
    };

    heatSimulation = new ui::Checkbox(ui::Point(8, 23), ui::Point(Size.X-6, 16), "Heat simulation \bgIntroduced in version 34", "");
    heatSimulation->SetActionCallback(new HeatSimulationAction(this));
    AddComponent(heatSimulation);
    tempLabel = new ui::Label(ui::Point(24, heatSimulation->Position.Y+14), ui::Point(Size.X-28, 16), "\bgCan cause odd behaviour when disabled");
    tempLabel->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
    tempLabel->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
    AddComponent(tempLabel);

    class AmbientHeatSimulationAction: public ui::CheckboxAction
    {
        OptionsView * v;
    public:
        AmbientHeatSimulationAction(OptionsView * v_) {
            v = v_;
        }
        virtual void ActionCallback(ui::Checkbox * sender) {
            v->c->SetAmbientHeatSimulation(sender->GetChecked());
        }
    };

    ambientHeatSimulation = new ui::Checkbox(ui::Point(8, 53), ui::Point(Size.X-6, 16), "Ambient heat simulation \bgIntroduced in version 50", "");
    ambientHeatSimulation->SetActionCallback(new AmbientHeatSimulationAction(this));
    AddComponent(ambientHeatSimulation);
    tempLabel = new ui::Label(ui::Point(24, ambientHeatSimulation->Position.Y+14), ui::Point(Size.X-28, 16), "\bgCan cause odd / broken behaviour with many saves");
    tempLabel->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
    tempLabel->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
    AddComponent(tempLabel);

    class NewtonianGravityAction: public ui::CheckboxAction
    {
        OptionsView * v;
    public:
        NewtonianGravityAction(OptionsView * v_) {
            v = v_;
        }
        virtual void ActionCallback(ui::Checkbox * sender) {
            v->c->SetNewtonianGravity(sender->GetChecked());
        }
    };

    newtonianGravity = new ui::Checkbox(ui::Point(8, 83), ui::Point(Size.X-6, 16), "Newtonian gravity \bgIntroduced in version 48", "");
    newtonianGravity->SetActionCallback(new NewtonianGravityAction(this));
    AddComponent(newtonianGravity);
    tempLabel = new ui::Label(ui::Point(24, newtonianGravity->Position.Y+14), ui::Point(Size.X-28, 16), "\bgMay cause poor performance on older computers");
    tempLabel->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
    tempLabel->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
    AddComponent(tempLabel);

    class WaterEqualisationAction: public ui::CheckboxAction
    {
        OptionsView * v;
    public:
        WaterEqualisationAction(OptionsView * v_) {
            v = v_;
        }
        virtual void ActionCallback(ui::Checkbox * sender) {
            v->c->SetWaterEqualisation(sender->GetChecked());
        }
    };

    waterEqualisation = new ui::Checkbox(ui::Point(8, 113), ui::Point(Size.X-6, 16), "Water equalisation \bgIntroduced in version 61", "");
    waterEqualisation->SetActionCallback(new WaterEqualisationAction(this));
    AddComponent(waterEqualisation);
    tempLabel = new ui::Label(ui::Point(24, waterEqualisation->Position.Y+14), ui::Point(Size.X-28, 16), "\bgMay cause poor performance with a lot of water");
    tempLabel->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
    tempLabel->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
    AddComponent(tempLabel);

    class AirModeChanged: public ui::DropDownAction
    {
        OptionsView * v;
    public:
        AirModeChanged(OptionsView * v): v(v) { }
        virtual void OptionChanged(ui::DropDown * sender, std::pair<std::string, int> option) {
            v->c->SetAirMode(option.second);
        }
    };
    airMode = new ui::DropDown(ui::Point(Size.X-88, 146), ui::Point(80, 16));
    AddComponent(airMode);
    airMode->AddOption(std::pair<std::string, int>("On", 0));
    airMode->AddOption(std::pair<std::string, int>("Pressure off", 1));
    airMode->AddOption(std::pair<std::string, int>("Velocity off", 2));
    airMode->AddOption(std::pair<std::string, int>("Off", 3));
    airMode->AddOption(std::pair<std::string, int>("No Update", 4));
    airMode->SetActionCallback(new AirModeChanged(this));

    tempLabel = new ui::Label(ui::Point(8, 146), ui::Point(Size.X-96, 16), "Air Simulation Mode");
    tempLabel->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
    tempLabel->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
    AddComponent(tempLabel);

    class GravityModeChanged: public ui::DropDownAction
    {
        OptionsView * v;
    public:
        GravityModeChanged(OptionsView * v): v(v) { }
        virtual void OptionChanged(ui::DropDown * sender, std::pair<std::string, int> option) {
            v->c->SetGravityMode(option.second);
        }
    };

    gravityMode = new ui::DropDown(ui::Point(Size.X-88, 166), ui::Point(80, 16));
    AddComponent(gravityMode);
    gravityMode->AddOption(std::pair<std::string, int>("Vertical", 0));
    gravityMode->AddOption(std::pair<std::string, int>("Off", 1));
    gravityMode->AddOption(std::pair<std::string, int>("Radial", 2));
    gravityMode->SetActionCallback(new GravityModeChanged(this));

    tempLabel = new ui::Label(ui::Point(8, 166), ui::Point(Size.X-96, 16), "Gravity Simulation Mode");
    tempLabel->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
    tempLabel->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
    AddComponent(tempLabel);

    class EdgeModeChanged: public ui::DropDownAction
    {
        OptionsView * v;
    public:
        EdgeModeChanged(OptionsView * v): v(v) { }
        virtual void OptionChanged(ui::DropDown * sender, std::pair<std::string, int> option) {
            v->c->SetEdgeMode(option.second);
        }
    };

    edgeMode = new ui::DropDown(ui::Point(Size.X-88, 186), ui::Point(80, 16));
    AddComponent(edgeMode);
    edgeMode->AddOption(std::pair<std::string, int>("Void", 0));
    edgeMode->AddOption(std::pair<std::string, int>("Solid", 1));
    edgeMode->AddOption(std::pair<std::string, int>("Loop", 2));
    edgeMode->SetActionCallback(new EdgeModeChanged(this));

    tempLabel = new ui::Label(ui::Point(8, 186), ui::Point(Size.X-96, 16), "Edge Mode");
    tempLabel->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
    tempLabel->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
    AddComponent(tempLabel);

    class ScaleAction: public ui::CheckboxAction
    {
        OptionsView * v;
    public:
        ScaleAction(OptionsView * v_) {
            v = v_;
        }
        virtual void ActionCallback(ui::Checkbox * sender) {
            v->c->SetScale(sender->GetChecked());
        }
    };

    scale = new ui::Checkbox(ui::Point(8, 210), ui::Point(Size.X-6, 16), "Large screen", "");
    scale->SetActionCallback(new ScaleAction(this));
    tempLabel = new ui::Label(ui::Point(scale->Position.X+Graphics::textwidth(scale->GetText().c_str())+20, scale->Position.Y), ui::Point(Size.X-28, 16), "\bg- Double window size for smaller screens");
    tempLabel->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
    tempLabel->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
    AddComponent(tempLabel);
    AddComponent(scale);


    class FullscreenAction: public ui::CheckboxAction
    {
        OptionsView * v;
    public:
        FullscreenAction(OptionsView * v_) {
            v = v_;
        }
        virtual void ActionCallback(ui::Checkbox * sender)
        {
#ifdef MACOSX
            ErrorMessage::Blocking("Error", "fullscreen doesn't work on OS X");
#else
            v->c->SetFullscreen(sender->GetChecked());
#endif
        }
    };

    fullscreen = new ui::Checkbox(ui::Point(8, 230), ui::Point(Size.X-6, 16), "Fullscreen", "");
    fullscreen->SetActionCallback(new FullscreenAction(this));
    tempLabel = new ui::Label(ui::Point(fullscreen->Position.X+Graphics::textwidth(fullscreen->GetText().c_str())+20, fullscreen->Position.Y), ui::Point(Size.X-28, 16), "\bg- Fill the entire screen");
    tempLabel->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
    tempLabel->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
    AddComponent(tempLabel);
    AddComponent(fullscreen);


    class FastQuitAction: public ui::CheckboxAction
    {
        OptionsView * v;
    public:
        FastQuitAction(OptionsView * v_) {
            v = v_;
        }
        virtual void ActionCallback(ui::Checkbox * sender) {
            v->c->SetFastQuit(sender->GetChecked());
        }
    };

    fastquit = new ui::Checkbox(ui::Point(8, 250), ui::Point(Size.X-6, 16), "Fast Quit", "");
    fastquit->SetActionCallback(new FastQuitAction(this));
    tempLabel = new ui::Label(ui::Point(fastquit->Position.X+Graphics::textwidth(fastquit->GetText().c_str())+20, fastquit->Position.Y), ui::Point(Size.X-28, 16), "\bg- Always exit completely when hitting close");
    tempLabel->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
    tempLabel->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
    AddComponent(tempLabel);
    AddComponent(fastquit);

    class ShowAvatarsAction: public ui::CheckboxAction
    {
        OptionsView * v;
    public:
        ShowAvatarsAction(OptionsView * v_) {
            v = v_;
        }
        virtual void ActionCallback(ui::Checkbox * sender) {
            v->c->SetShowAvatars(sender->GetChecked());
        }
    };

    showAvatars = new ui::Checkbox(ui::Point(8, 270), ui::Point(Size.X-6, 16), "Show Avatars", "");
    showAvatars->SetActionCallback(new ShowAvatarsAction(this));
    tempLabel = new ui::Label(ui::Point(showAvatars->Position.X+Graphics::textwidth(showAvatars->GetText().c_str())+20, showAvatars->Position.Y), ui::Point(Size.X-28, 16), "\bg- Disable if you have a slow connection");
    tempLabel->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
    tempLabel->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
    AddComponent(tempLabel);
    AddComponent(showAvatars);

    class DataFolderAction: public ui::ButtonAction
    {
    public:
        DataFolderAction() { }
        void ActionCallback(ui::Button * sender)
        {
//one of these should always be defined
#ifdef WIN
            const char* openCommand = "explorer ";
#elif MACOSX
            const char* openCommand = "open ";
//#elif LIN
#else
            const char* openCommand = "xdg-open ";
#endif
            char* workingDirectory = new char[FILENAME_MAX+strlen(openCommand)];
            sprintf(workingDirectory, "%s\"%s\"", openCommand, getcwd(NULL, 0));
            system(workingDirectory);
            delete[] workingDirectory;
        }
    };
    ui::Button * dataFolderButton = new ui::Button(ui::Point(8, Size.Y-38), ui::Point(90, 16), "Open Data Folder");
    dataFolderButton->SetActionCallback(new DataFolderAction());
    AddComponent(dataFolderButton);

    tempLabel = new ui::Label(ui::Point(dataFolderButton->Position.X+dataFolderButton->Size.X+3, dataFolderButton->Position.Y), ui::Point(Size.X-28, 16), "\bg- Open the data and preferences folder");
    tempLabel->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
    tempLabel->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
    AddComponent(tempLabel);

    class CloseAction: public ui::ButtonAction
    {
    public:
        OptionsView * v;
        CloseAction(OptionsView * v_) {
            v = v_;
        }
        void ActionCallback(ui::Button * sender)
        {
            v->c->Exit();
        }
    };

    ui::Button * tempButton = new ui::Button(ui::Point(0, Size.Y-16), ui::Point(Size.X, 16), "OK");
    tempButton->SetActionCallback(new CloseAction(this));
    AddComponent(tempButton);
    SetCancelButton(tempButton);
    SetOkayButton(tempButton);
}
예제 #16
0
ColourPickerActivity::ColourPickerActivity(ui::Colour initialColour, ColourPickedCallback * callback) :
	WindowActivity(ui::Point(-1, -1), ui::Point(266, 175)),
	currentHue(0),
	currentSaturation(0),
	currentValue(0),
	mouseDown(false),
	valueMouseDown(false),
	callback(callback)
{

	class ColourChange : public ui::TextboxAction
	{
		ColourPickerActivity * a;
	public:
		ColourChange(ColourPickerActivity * a) : a(a) {}

		void TextChangedCallback(ui::Textbox * sender)
		{
			int r, g, b;
			r = format::StringToNumber<int>(a->rValue->GetText());
			g = format::StringToNumber<int>(a->gValue->GetText());
			b = format::StringToNumber<int>(a->bValue->GetText());
			RGB_to_HSV(r, g, b, &a->currentHue, &a->currentSaturation, &a->currentValue);
		}
	};

	rValue = new ui::Textbox(ui::Point(5, Size.Y-23), ui::Point(30, 17), "255");
	rValue->SetActionCallback(new ColourChange(this));
	rValue->SetLimit(3);
	rValue->SetInputType(ui::Textbox::Number);
	AddComponent(rValue);

	gValue = new ui::Textbox(ui::Point(40, Size.Y-23), ui::Point(30, 17), "255");
	gValue->SetActionCallback(new ColourChange(this));
	gValue->SetLimit(3);
	gValue->SetInputType(ui::Textbox::Number);
	AddComponent(gValue);

	bValue = new ui::Textbox(ui::Point(75, Size.Y-23), ui::Point(30, 17), "255");
	bValue->SetActionCallback(new ColourChange(this));
	bValue->SetLimit(3);
	bValue->SetInputType(ui::Textbox::Number);
	AddComponent(bValue);

	class CancelAction: public ui::ButtonAction
	{
		ColourPickerActivity * a;
	public:
		CancelAction(ColourPickerActivity * a) : a(a) { }
		void ActionCallback(ui::Button * sender)
		{
			a->Exit();
		}
	};

	class OkayAction: public ui::ButtonAction
	{
		ColourPickerActivity * a;
	public:
		OkayAction(ColourPickerActivity * a) : a(a) { }
		void ActionCallback(ui::Button * sender)
		{
			int Red, Green, Blue;
			HSV_to_RGB(a->currentHue, a->currentSaturation, a->currentValue, &Red, &Green, &Blue);
			ui::Colour col(Red, Green, Blue);
			if(a->callback)
				a->callback->ColourPicked(col);
			a->Exit();
		}
	};

	ui::Button * doneButton = new ui::Button(ui::Point(Size.X-45, Size.Y-23), ui::Point(40, 17), "Done");
	doneButton->SetActionCallback(new OkayAction(this));
	AddComponent(doneButton);
	SetOkayButton(doneButton);

	ui::Button * cancelButton = new ui::Button(ui::Point(Size.X-90, Size.Y-23), ui::Point(40, 17), "Cancel");
	cancelButton->SetActionCallback(new CancelAction(this));
	AddComponent(cancelButton);
	SetCancelButton(cancelButton);

	rValue->SetText(format::NumberToString<int>(initialColour.Red));
	gValue->SetText(format::NumberToString<int>(initialColour.Green));
	bValue->SetText(format::NumberToString<int>(initialColour.Blue));
	RGB_to_HSV(initialColour.Red, initialColour.Green, initialColour.Blue, &currentHue, &currentSaturation, &currentValue);
}
예제 #17
0
SetZDepth::SetZDepth(Actor *actor, bool bOnCollision)
	: BaseAction("Set ZDepth", (GameControl::Get()->Width() - WIDTH)/2, 
				          (GameControl::Get()->Height() - HEIGHT)/2,
						  WIDTH, HEIGHT)
{
	SetModal();
	SetToolTip(TIP_CHANGE_ZDEPTH);
	eventActor = actionActor = actor;
	

	Text *text;
	Button *button;	
	int y;

	//Title
	text = AddText(CHANGE_ZDEPTH, CENTER_TEXT, 5);
	y = DrawHLine(text->Down() + 2);

	//Body
	text = AddText("       Actor: ", 10, y);
	listActor = AddListPop(text->Right() + 2, text->Top(), 128, 0, LS_ACTOR); listActor->SetToolTip(gedString(TIP_CHANGE_ZDEPTH_ACTOR) + TIP_ACTION_ACTOR);
	text = AddText("     Z Depth: ", 10, listActor->Down() + 2);
	slide = AddSlide(text->Right(), text->Top(), 100, 14, SL_TRANS); slide->SetToolTip(TIP_CHANGE_ZDEPTH_AMOUNT);
	
	
	//Close
	y = DrawHLine(slide->Down() + 2);
	button = AddButton(Action::getEditAction()?"Ok":"Add", 55, y, 0, 0, BT_ADD); button->SetToolTip(TIP_ACTION_ADD); SetConfirmButton(button);
	button = AddButton("Cancel", button->Right()+8, y, 0, 0, BT_CLOSE); button->SetToolTip(TIP_ACTION_CANCEL); SetCancelButton(button);


	GameControl::Get()->PopulateActors(listActor);
	
	listActor->AddText(S_EVENT_ACTOR);

	if(Tutorial::IsCompatible(VERSION_OUT_OF_VISION_OPTIMIZATION))
	{
		listActor->AddText(S_PARENT_ACTOR);
		listActor->AddText(S_CREATOR_ACTOR);
	}

	if(bOnCollision) listActor->AddText(S_COLLIDE_ACTOR);
	listActor->SetItem(S_EVENT_ACTOR);

	oriZDepth = actionActor->getImage()->ZDepth();

	if(!ExpressionEditor::getExpressionEditor()) UpdateEdition();
}
예제 #18
0
DestroyTimer::DestroyTimer(Actor *actor)
	: BaseAction("Destroy Timer", (GameControl::Get()->Width() - WIDTH)/2, 
				          (GameControl::Get()->Height() - HEIGHT)/2,
						  WIDTH, HEIGHT)
{
	SetModal();
	SetToolTip(TIP_DESTROYTIMER);
	eventActor = actionActor = actor;

	Text *text;
	Button *button;	
	int y;

	//Title
	text = AddText(DESTROY_TIMER, CENTER_TEXT, 5);
	y = DrawHLine(text->Down() + 2);

	//Body
	text = AddText("   Timer: ", 10, y);
	listTimer = AddListPop(text->Right() + 2, text->Top(), 300, 0, LS_TIMER); listTimer->SetToolTip(TIP_DESTROYTIMER_TIMER);
	
	
	//Close
	y = DrawHLine(listTimer->Down() + 2);
	button = AddButton(Action::getEditAction()?"Ok":"Add", (WIDTH-135)/2, y, 0, 0, BT_ADD); button->SetToolTip(TIP_ACTION_ADD); SetConfirmButton(button);
	button = AddButton("Cancel", button->Right()+8, y, 0, 0, BT_CLOSE); button->SetToolTip(TIP_ACTION_CANCEL); SetCancelButton(button);

	GameControl::Get()->PopulateTimers(listTimer);			
	listTimer->SetItem(listTimer->GetText(0));

	if(!ExpressionEditor::getExpressionEditor()) UpdateEdition();
}
InformationMessage::InformationMessage(std::string title, std::string message, bool large):
	ui::Window(ui::Point(-1, -1), ui::Point(200, 35))
{
	if (large) //Maybe also use this large mode for changelogs eventually, or have it as a customizable size?
	{
		Size.X += 200;
		Size.Y += 215;
	}

	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::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-8, -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);

		if (messageLabel->Size.Y < messagePanel->Size.Y)
			messagePanel->Size.Y = messageLabel->Size.Y+4;
		Size.Y += messagePanel->Size.Y+12;
		Position.Y = (ui::Engine::Ref().GetHeight()-Size.Y)/2;
	}

	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);

	class DismissAction: public ui::ButtonAction
	{
		InformationMessage * message;
	public:
		DismissAction(InformationMessage * message_) { message = message_; }
		void ActionCallback(ui::Button * sender)
		{
			ui::Engine::Ref().CloseWindow();
			message->SelfDestruct(); //TODO: Fix component disposal
		}
	};

	ui::Button * okayButton = new ui::Button(ui::Point(0, Size.Y-16), ui::Point(Size.X, 16), "Dismiss");
	okayButton->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
	okayButton->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
	okayButton->Appearance.BorderInactive = ui::Colour(200, 200, 200);
	okayButton->SetActionCallback(new DismissAction(this));
	AddComponent(okayButton);
	SetOkayButton(okayButton);
	SetCancelButton(okayButton);
	
	ui::Engine::Ref().ShowWindow(this);
}
예제 #20
0
ServerSaveActivity::ServerSaveActivity(SaveInfo save, ServerSaveActivity::SaveUploadedCallback * callback) :
	WindowActivity(ui::Point(-1, -1), ui::Point(440, 200)),
	thumbnail(NULL),
	save(save),
	callback(callback),
	saveUploadTask(NULL)
{
	titleLabel = new ui::Label(ui::Point(4, 5), ui::Point((Size.X/2)-8, 16), "");
	titleLabel->SetTextColour(style::Colour::InformationTitle);
	titleLabel->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
	titleLabel->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
	AddComponent(titleLabel);
	CheckName(save.GetName()); //set titleLabel text

	ui::Label * previewLabel = new ui::Label(ui::Point((Size.X/2)+4, 5), ui::Point((Size.X/2)-8, 16), "Preview:");
	previewLabel->SetTextColour(style::Colour::InformationTitle);
	previewLabel->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
	previewLabel->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
	AddComponent(previewLabel);

	nameField = new ui::Textbox(ui::Point(8, 25), ui::Point((Size.X/2)-16, 16), save.GetName(), "[save name]");
	nameField->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
	nameField->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
	nameField->SetActionCallback(new NameChangedAction(this));
	AddComponent(nameField);
	FocusComponent(nameField);

	descriptionField = new ui::Textbox(ui::Point(8, 65), ui::Point((Size.X/2)-16, Size.Y-(65+16+4)), save.GetDescription(), "[save description]");
	descriptionField->SetMultiline(true);
	descriptionField->SetLimit(254);
	descriptionField->Appearance.VerticalAlign = ui::Appearance::AlignTop;
	descriptionField->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
	AddComponent(descriptionField);

	publishedCheckbox = new ui::Checkbox(ui::Point(8, 45), ui::Point((Size.X/2)-80, 16), "Publish", "");
	if(Client::Ref().GetAuthUser().Username != save.GetUserName())
	{
		//Save is not owned by the user, disable by default
		publishedCheckbox->SetChecked(false);	
	}
	else
	{
		//Save belongs to the current user, use published state already set
		publishedCheckbox->SetChecked(save.GetPublished());
	}
	AddComponent(publishedCheckbox);

	pausedCheckbox = new ui::Checkbox(ui::Point(160, 45), ui::Point(55, 16), "Paused", "");
	pausedCheckbox->SetChecked(save.GetGameSave()->paused);
	AddComponent(pausedCheckbox);

	ui::Button * cancelButton = new ui::Button(ui::Point(0, Size.Y-16), ui::Point((Size.X/2)-75, 16), "Cancel");
	cancelButton->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
	cancelButton->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
	cancelButton->Appearance.BorderInactive = ui::Colour(200, 200, 200);
	cancelButton->SetActionCallback(new CancelAction(this));
	AddComponent(cancelButton);
	SetCancelButton(cancelButton);

	ui::Button * okayButton = new ui::Button(ui::Point((Size.X/2)-76, Size.Y-16), ui::Point(76, 16), "Save");
	okayButton->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
	okayButton->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
	okayButton->Appearance.TextInactive = style::Colour::InformationTitle;
	okayButton->SetActionCallback(new SaveAction(this));
	AddComponent(okayButton);
	SetOkayButton(okayButton);

	ui::Button * PublishingInfoButton = new ui::Button(ui::Point((Size.X*3/4)-75, Size.Y-42), ui::Point(150, 16), "Publishing Info");
	PublishingInfoButton->Appearance.HorizontalAlign = ui::Appearance::AlignCentre;
	PublishingInfoButton->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
	PublishingInfoButton->Appearance.TextInactive = style::Colour::InformationTitle;
	PublishingInfoButton->SetActionCallback(new PublishingAction(this));
	AddComponent(PublishingInfoButton);

	ui::Button * RulesButton = new ui::Button(ui::Point((Size.X*3/4)-75, Size.Y-22), 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);
}
예제 #21
0
PanelQuestion::PanelQuestion(gedString text, gedString title, gedString confirmButton, gedString cancelButton, int align)
: PanelInfo(text, title, align, false)
{
	Button *button1, *button2 = NULL;

	button1 = AddButton(confirmButton, 0, lastLine, 0, 0, OK_BUTTON); SetConfirmButton(button1);
	if(cancelButton != NO_BUTTON)
	{
		button2 = AddButton(cancelButton, button1->Right()+8, lastLine, 0, 0, CANCEL_BUTTON); SetCancelButton(button2);
	}

	//Center
	int widthButtons = button1->Width();
	if(button2) widthButtons += button2->Width() + 8;

	button1->SetPos((Width() - widthButtons)/2, lastLine);
	if(button2) button2->SetPos(button1->Right()+8, lastLine);
}