Beispiel #1
0
static void *
devicecallback (void *arg)
{
  while (1)
  {
    if(isMounted[DEVICE_SD])
    {
      if(!sd->isInserted()) // check if the device was removed
      {
        unmountRequired[DEVICE_SD] = true;
        isMounted[DEVICE_SD] = false;
      }
    }

    if(isMounted[DEVICE_USB])
    {
      if(!usb->isInserted()) // check if the device was removed
      {
        unmountRequired[DEVICE_USB] = true;
        isMounted[DEVICE_USB] = false;
      }
    }

    devsleep = 1000*1000; // 1 sec

    while(devsleep > 0)
    {
      if(deviceHalt)
        LWP_SuspendThread(devicethread);
      usleep(THREAD_SLEEP);
      devsleep -= THREAD_SLEEP;
    }
    UpdateCheck();
  }
  return NULL;
}
Beispiel #2
0
bool MainPanel::OnList(ListPop *list, int index, gedString &text, int listId)
{
	if(listEditBox) 
	{
		delete listEditBox;
		listEditBox = NULL;
	}

	switch(listId)
	{
	case LS_FILE:
		{			
			if(text == "New Game")
			{
				/*<Odilon>
				  Verifica se nao foi feito nada, ainda, para
				  pedir confirmacao apenas se necessario.
				*/
				
				if (GameControl::Get()->Modified())
				{
					//<Odilon> Pequena correcao de Ingles...
					PanelQuestion *panel = new PanelQuestion("This will discard the current game.\nProceed anyway?");
					///PanelQuestion *panel = new PanelQuestion("This action will erase the current game.\nTo proceed?");
					
					if(panel->Wait() == OK_BUTTON)
					{
						GameControl::Get()->NewGame();
						UndoControl::Get()->Clear();
						lastScripts.Clear();

						
						ExportGame::ClearExportName();
						
						/*Close actor dialog*/
						ActorProperty::Destroy();
					}
					
					delete panel;
					
				}
				else  //nao eh necessario confirmar; nada foi feito.
				{
					/* Aqui estou repetindo o mesmo codigo acima,...
					   talvez seja melhor encontrar outra maneira de fazer isso,
					   ou talvez nao... */
			
					GameControl::Get()->NewGame();
					UndoControl::Get()->Clear();
					lastScripts.Clear();

					/*Close actor dialog*/
					ActorProperty::Destroy();
				}
				
			}
			else if(text == "Load")
			{
				new LoadSaveGame(LOAD_GAME);

				ExportGame::ClearExportName();
				
			}
			else if(text == "Merge")
			{
				new LoadSaveGame(MERGE_GAME);
			}
#ifdef USE_SYSTEM_FILE_DIALOG
			else if(text == "Save As...")
			{
				new LoadSaveGame(SAVE_GAME);
				ExportGame::ClearExportName();
			}
			else if(text == "Save")
			{
				if(Tutorial::IsOff())
				{
					gedString gamePath(GameControl::Get()->getGamePath());

					if(!gamePath.empty())
					{
						LoadSaveGame::Save(gamePath + DIR_SEP + GameControl::Get()->getGameName());
					}
					else
					{
						new LoadSaveGame(SAVE_GAME);
					}
				}
				else
				{
					new LoadSaveGame(SAVE_GAME);
				}
			}
#else
			else if(text == "Save")
			{
				new LoadSaveGame(SAVE_GAME);
			}
#endif			
			else if(text == "Export")
			{
				#ifdef GAME_EDITOR_PROFESSIONAL

				if(GenericScript::ParserAll())
				{
					new ExportGame();
				}
				else
				{
					new PanelInfo(GenericScript::GetError(), "Error", ALIGN_LEFT);
				}
				
				#else 
				new PanelInfo(GAME_EDITOR_VERSION_ERROR);
				#endif
			}
			else if(text == "Exit")
			{
				//Exit
				SDL_Event event;
				memset(&event, 0, sizeof(SDL_Event));
				event.quit.type = SDL_QUIT;
				SDL_PushEvent(&event);
			}
			else
			{
				//Recent file list
				gedString *sFile = (gedString *)listFile->GetItemData(index);
				if(sFile)
				{
					LoadGame(*sFile, true);
				}
			}		
		}
		break;
	case LS_SETTINGS:
		{
			if(text == "Game Properties")
			{
				new GameSettings();
			}
			else if(text == "Preferences")
			{
				new Preferences();
			}
			else if(text == "Disable Tool Tips")
			{
				Config::Get()->setEnableToolTips(false);
				
				gedString *pEnableDisableToolTips = listConfig->GetTextPtr("Disable Tool Tips");
				if(pEnableDisableToolTips)
				{
					*pEnableDisableToolTips = "Enable Tool Tips";
				}
			}
			else if(text == "Enable Tool Tips")
			{
				Config::Get()->setEnableToolTips(true);
				
				gedString *pEnableDisableToolTips = listConfig->GetTextPtr("Enable Tool Tips");
				if(pEnableDisableToolTips)
				{
					*pEnableDisableToolTips = "Disable Tool Tips";
				}
			}
		}
		break;
	case LS_REGIONS:
		{
			switch(index)
			{
			case 0: //Add Activation Region
#if !defined(GAME_EDITOR_HOME_EDITION)
				new RegionLoad();	
#else
				new PanelInfo(GAME_EDITOR_VERSION_ERROR);
				return true;
#endif
				break;
			case 1: //show/hide
				
				if(RegionLoad::getShowRegions())
				{
					*pShowHideRegions = "Show Regions";
				}
				else
				{
					*pShowHideRegions = "Hide Regions";
				}

				RegionLoad::ToggleVisibility();
				Actor::RegionActorToggleVisibility();
				break;
			}
		}
		break;
	case LS_HELP:
		{
			if(text == "Documentation")
			{
				EditorDirectory editDir;
				
				//Firefox don't open "Docs/index.html" in windows
				//So, use \ on windows and / on linux
			
				openUrl((
#if defined(__MACOSX__)
		gedString("file://")+	GameControl::Get()->getHomePath()+gedString("/")+		 
#endif
						 
						 gedString("Docs") + DIR_SEP + "index.html").c_str());
			}
			else if(text == "About...")
			{
				new AboutDlg();
			}
			else if(text == "User Forums...")
			{
				openUrl("http://game-editor.com/forum");
			}	
#if !defined(__MACOSX__)
			else if(text == "Get Newest Tutorials...")
			{
				TutorialUpdateDlg::Call();
			}
			else if(text == "Check for Updates...")
			{
				UpdateCheck();
			}
#endif // No check for updates outside MACOSX appstore due to apple guidelines
			else if(text == "Game Demos...")
			{
				openUrl("http://game-editor.com/demos.html");				
			}
			else
			{
				//Tutorials
				if(chdir((GameControl::getEditorPath() + DIR_SEP + "Tutorials" + DIR_SEP + text).c_str()) == 0)
				{				
					listTutorialDir->RemoveAll();
					listTutorialDir->getImage()->SetVisible(true);				
					PostMessage(this, 0);
				}
			}
		}
		break;
	case LS_TUTORIALDIR:
		{		
			PanelQuestion *panel = new PanelQuestion("This will discard the current game.\nProceed anyway?", "Tutorial Execution");
			if(panel->Wait() == OK_BUTTON)
			{
				PostMessage(this, 1);					
			}

			delete panel;	
			
		}
		break;

	case LS_EDIT_MENU:
		{
			switch(index)
			{
			case 0:
				editBoxWidget->Cut();
				break;

			case 1:
				editBoxWidget->Copy();
				break;

			case 2:
				editBoxWidget->Paste();
				break;
			}			
		}
		break;

	case LS_SCRIPT:
		{
			if(text == "Global code")
			{
				new ScriptGlobals();
			}
			else
			{
				stAction *action = (stAction *)list->GetItemData(index);
				gedString actorName(text.substr(0, text.find(' ')));

				Actor *actor = GameControl::Get()->GetActor(actorName);								

				if(actor && action)
				{
					AddLastScript(text);
					Action::ShowActionDialog(action, actor);			
				}
			}
		}
		break;
	}

	return true;
}