void UIScreen::LoadGroup()
{
	//Logger::Debug("load group started");
	//uint64 loadGroupStart = SystemTimer::Instance()->AbsoluteMS();
	if (groupId < 0)
	{
		if (isLoaded)return;
		
		LoadResources();
		isLoaded = true;
	}else
	{
		for (List<UIScreen*>::iterator t = appScreens.begin(); t != appScreens.end(); ++t)
		{
			UIScreen * screen = *t;
			if ((screen->groupId == groupId) && (!screen->isLoaded))
			{
				screen->LoadResources();
				screen->isLoaded = true;
			}
		}
	}
	//uint64 loadGroupEnd = SystemTimer::Instance()->AbsoluteMS();
	//Logger::Debug("load group finished: %lld", loadGroupEnd - loadGroupStart);
}
Exemple #2
0
void LandscapeToolsPanel::UpdateRect()
{
    UIScreen *activeScreen = UIScreenManager::Instance()->GetScreen();
    if(activeScreen)
    {
        Vector2 screenSize = activeScreen->GetSize();
        
        Vector2 panelSize = this->GetSize();
        Vector2 panelPosition = this->GetPosition();

        this->SetSize(Vector2(screenSize.x - EditorSettings::Instance()->GetRightPanelWidth(), panelSize.y));
        this->SetPosition(Vector2(0, panelPosition.y));
    }
}
Exemple #3
0
UIScreen* UISystem_Impl::CreateUIScreen()
{
	UIScreen* pScreen = new UIScreen();
	if (!pScreen || !pScreen->IsOK())
	{
		SAFE_DELETE(pScreen);
		return NULL;
	}

	pScreen->SetPosition(IMath::VEC2_ZERO);
	pScreen->SetSize(ScreenUtil::GetInstance().GetScreenSize());
	m_vUIScreen.push_back(pScreen);

	return pScreen;
}
void SettingsDialog::WillAppear()
{
    propertyList->SetIntPropertyValue("settingsdialog.screenwidth", EditorSettings::Instance()->GetScreenWidth());
    propertyList->SetIntPropertyValue("settingsdialog.screenheight", EditorSettings::Instance()->GetScreenHeight());
    propertyList->SetFloatPropertyValue("settingsdialog.autosave", EditorSettings::Instance()->GetAutosaveTime());
    
    String language = EditorSettings::Instance()->GetLanguage();
    int32 index = 0;
    for(int32 i = 0; i < (int32)languages.size(); ++i)
    {
        if(language == languages[i])
        {
            index = i;
            break;
        }
    }
    propertyList->SetComboPropertyIndex("settingsdialog.language", index);
    propertyList->SetBoolPropertyValue("settingsdialog.output", EditorSettings::Instance()->GetShowOutput());
    
    propertyList->SetFloatPropertyValue("settingsdialog.cameraspeed1", EditorSettings::Instance()->GetCameraSpeed(0));
    propertyList->SetFloatPropertyValue("settingsdialog.cameraspeed2", EditorSettings::Instance()->GetCameraSpeed(1));
    propertyList->SetFloatPropertyValue("settingsdialog.cameraspeed3", EditorSettings::Instance()->GetCameraSpeed(2));
    propertyList->SetFloatPropertyValue("settingsdialog.cameraspeed4", EditorSettings::Instance()->GetCameraSpeed(3));
    
    propertyList->SetIntPropertyValue("settingsdialog.leftpanelwidth", EditorSettings::Instance()->GetLeftPanelWidth());
    propertyList->SetIntPropertyValue("settingsdialog.rightpanelwidth", EditorSettings::Instance()->GetRightPanelWidth());
    
    propertyList->SetBoolPropertyValue("settingsdialog.drawgrid", EditorSettings::Instance()->GetDrawGrid());
	propertyList->SetBoolPropertyValue("settingsdialog.imposters", EditorSettings::Instance()->GetEnableImposters());
    
    
    UIScreen *activeScreen = UIScreenManager::Instance()->GetScreen();
    if(activeScreen)
    {
        Vector2 screenSize = activeScreen->GetSize();
        Vector2 dialogSize = dialogPanel->GetSize();
        dialogPanel->SetPosition((screenSize - dialogSize) / 2);

        this->SetSize(screenSize);
    }
}
Exemple #5
0
void TextureConverterDialog::Show(Scene * scene)
{
    if(!GetParent())
    {
        SafeRelease(workingScene);
        workingScene = SafeRetain(scene);
        
        selectedTextureName = "";
        EnumerateTextures();
        
        selectedItem = -1;
        textureList->Refresh();
        if(textures.size())
        {
            textureList->ScrollToElement(0);
        }
        
        UIScreen *screen = UIScreenManager::Instance()->GetScreen();
        screen->AddControl(this);
    }
}
void UIScreen::UnloadGroup()
{
	if (groupId < 0)
	{
		if (!isLoaded)return;
		
		UnloadResources();
		isLoaded = false;
	}else
	{
		for (List<UIScreen*>::iterator t = appScreens.begin(); t != appScreens.end(); ++t)
		{
			UIScreen * screen = *t;
			if ((screen->groupId == groupId) && (screen->isLoaded))
			{
				screen->UnloadResources();
				screen->isLoaded = false;
			}
		}
	}	
}
void ComboBox::OnButton(BaseObject * object, void * userData, void * callerData)
{
    if (list->GetParent()) 
    {
        Cancel();
    }
    else 
    {
        if(parent)
        {
            parent->BringChildFront(this);
        }

        
        UIScreen *screen = UIScreenManager::Instance()->GetScreen();
        if(screen)
        {
            Rect buttonRect = GetRect(true);
            Rect screenRect = screen->GetRect(true);
            
            float32 toRight = (screenRect.x + screenRect.dx) - (buttonRect.x);
            if(toRight < listWidth)
            {
                list->SetPosition(Vector2(buttonRect.x + buttonRect.dx - listWidth, buttonRect.y + buttonRect.dy));
            }
            else 
            {
                list->SetPosition(Vector2(buttonRect.x, buttonRect.y + buttonRect.dy));
            }

            screen->AddControl(list);
        }
        
        comboButton->SetSelected(true);
        list->Refresh();
    }

}
void UIManager::HandleEvent(string eventName, list<string> params)
{
	int action = m_ActionStringToEnumMap[eventName];

	switch (action)
	{
	case PUSH_UI:
		{
			string ui_name = *(params.begin()); // always only 1 parameter
			PushUI(ui_name); 
			if (ui_name == "mainmenu")
			{
				GameObjectManager::Instance()->SetLevelFreshLaunch(true);
			}
			break;
		}
	case POP_UI:
		{
			string ui_name = *(params.begin()); // always only 1 parameter
			PopUI(ui_name); 
			break;
		}
	case LOAD_LEVEL:
		{
			string level_file = *(params.begin()); // always only 1 parameter
			Game::SetIsLevelEditMode(false);
			auto inputManager = Game::GetInstance()->GetInputManager();
			inputManager.EnableDebugInfo(false);
			inputManager.EnablePostProcessing(false);
			GameObjectManager::Instance()->LoadObjectsFromFile(level_file.c_str());
			break;
		}
	case PLAY_SOUND_EFFECT:
		{
			list<string>::iterator iter = params.begin();
			string sound_file = (*iter); // first param is the audio file

			// second param is optional and is the loop bool
			bool loop = false;
			iter++;
			if (iter != params.end())
			{
				string boolean = (*iter);
				if ((*iter) == "true") loop = true; 
			}

			AudioManager::Instance()->PlaySoundEffect(sound_file, loop);
			break;
		}
	case PLAY_MUSIC:
		{
			list<string>::iterator iter = params.begin();
			string sound_file = (*iter); // first param is the audio file

			// second param is optional and is the loop bool
			bool loop = false;
			iter++;
			if (iter != params.end())
			{
				string boolean = (*iter);
				if ((*iter) == "true") loop = true; 
			}

			AudioManager::Instance()->PlayMusic(sound_file, loop);
			break;
		}
	case REFRESH_UI:
		{
			RefreshUI();
			break;
		}
	case STOP_ALL_SOUNDS:
		{
			AudioManager::Instance()->StopAllSounds();
			break;
		}
	case PAUSE_GAME:
		{
			Game::PauseGame();
			break;
		}
	case UNPAUSE_GAME:
		{
			Game::UnPauseGame();
			break;
		}
	case DESTROY_LEVEL:
		{
			Game::SetIsLevelEditMode(false);
			Game::GetInstance()->ResetLevelEditor();
			GameObjectManager::Instance()->DeleteGameObjects();
			break;
		}
	case SLEEP:
		{
			list<string>::iterator iter = params.begin();
			int milliseconds = atoi((*iter).c_str());
			Sleep(milliseconds);
		}
	case APPLY_ALPHA:
		{
			list<string>::iterator iter = params.begin();
			string ui = (*iter); 
			iter++;
			float alpha = atof((*iter).c_str());
			m_allScreens[ui]->ApplyAlpha(alpha);
			break;
		}
	case FADE_OUT:
		{
			list<string>::iterator iter = params.begin();
			int milliseconds = atoi((*iter).c_str());

			// start fading out - we do 10 passes 
			UIScreen * screen = PushUI("fullscreen_fade");
			screen->ApplyAlpha(0.0);
			float count = 0.0f;

			while (count < 1.0f)
			{
				screen->ApplyAlpha(count);
				RefreshUI();
				Sleep(milliseconds * 0.05f); // TODO: this is terrible bleugh, get rid of this crap
				count+= 0.05;
			}

			PopUI("fullscreen_fade");
			break;
		}
	case FADE_IN:
		{
			list<string>::iterator iter = params.begin();
			int milliseconds = atoi((*iter).c_str());

			// start fading out - we do 10 passes 
			UIScreen * screen = PushUI("fullscreen_fade");
			screen->ApplyAlpha(1.0);
			float count = 1.0;

			while (count > 0)
			{
				screen->ApplyAlpha(count);
				RefreshUI();
				Sleep(milliseconds/10);
				count-= 0.05;
			}

			PopUI("fullscreen_fade");
			break;
		}
	case MUTE_SOUND_EFFECTS:
		{
			AudioManager::Instance()->SetSfxEnabled(false);
			Settings::GetInstance()->SetSfxEnabled(false, true);
			break;
		}
	case MUTE_MUSIC:
		{
			AudioManager::Instance()->SetMusicEnabled(false);
			Settings::GetInstance()->SetMusicEnabled(false, true);
			break;
		}
	case UNMUTE_MUSIC:
		{
			AudioManager::Instance()->SetMusicEnabled(false);
			Settings::GetInstance()->SetMusicEnabled(true, true);
			break;
		}
	case UNMUTE_SOUND_EFFECTS:
		{
			AudioManager::Instance()->SetSfxEnabled(true);
			Settings::GetInstance()->SetSfxEnabled(true, true);
			break;
		}
	case QUIT_TO_DESKTOP:
		{
			PostDestroyMessage(); // evil global from program.cpp
			break;
		}
	case LEVEL_EDIT:
		{
			Game::GetInstance()->ResetLevelEditor();
			// only allow level editing if the back buffer is 1920x1080
			// this needs to be fixed at a later time
			if (Graphics::GetInstance()->BackBufferWidth() == 1920 &&
				Graphics::GetInstance()->BackBufferHeight() == 1080)
			{
				list<string>::iterator iter = params.begin();
				const char * level = (*iter).c_str();
				Game::SetIsLevelEditMode(true);
				GameObjectManager::Instance()->LoadObjectsFromFile(level);
			}
			auto inputManager = Game::GetInstance()->GetInputManager();
			inputManager.EnableDebugInfo(true);
			inputManager.EnablePostProcessing(true);
			break;			
		}
	case SET_LANGUAGE:
		{
			list<string>::iterator iter = params.begin();
			std::string lang = (*iter).c_str();
			StringManager::GetInstance()->SetLocale(lang);
			break;
		}

	default:
		break;
	};
}