Beispiel #1
0
bool CSrScriptView::CheckCanClose (void)
{
	CString Buffer;
	bool	fResult;
	int     Result;

	GetControlData();

	for (dword i = 0; i < m_Scripts.GetSize(); ++i)
	{
		if (!m_Scripts[i]->IsModified()) continue;
		
		Buffer.Format("Script '%s' has not been saved. Do you wish to save now?", m_Scripts[i]->GetScriptName());

		Result = AfxMessageBox(Buffer, MB_YESNOCANCEL | MB_ICONEXCLAMATION);
		if (Result == IDCANCEL) return false;

		if (Result == IDYES)
		{
			fResult = SaveScript(m_Scripts[i]);
			if (!fResult) return false;
		}
	}

	return true;
}
void __fastcall TfrmSearch::menuOpenScriptClick(TObject *Sender)
{
  if(SkyEdit2->Modified)
  {
    switch(MessageBox(Handle,"是否保存所做的修改?","问题",MB_ICONWARNING | MB_YESNOCANCEL))
    {
    case IDYES:
      if(!SaveScript())
        return;
      break;
    case IDNO:
      break;
    default:
      return;
    }
  }
  if(!OpenDialog1->Execute())
    return;
  try
  {
    SkyEdit2->Lines->LoadFromFile(OpenDialog1->FileName);
    SkyEdit2->SelLength = 0;
    CurScriptFileName = OpenDialog1->FileName;
  }
  catch(Exception * E)
  {
    MessageBox(Handle,E->Message.c_str(),"错误",MB_OK | MB_ICONSTOP);
    return;
  }
  SkyEdit2->Modified = false;
  labScriptFile->Caption = CurScriptFileName;
}
void __fastcall TfrmSearch::menuSaveClick(TObject *Sender)
{
  if(CurScriptFileName == "" && SkyEdit2->Text == "")
    return;
  if(!SaveScript())
    return;
  MessageBox(Handle,"查询脚本已保存!","信息",MB_OK | MB_ICONINFORMATION);
}
Beispiel #4
0
void Cmd_TextureMix()
{
    miptex32_t		*qtex32;
    char			filename[1024];
    int				size;

    InitVars();

    GetScriptToken (false);

    strcpy(root, token);
    RemoveExt(root);
    RemoveLeading(root);

    strcpy(filename, ExpandPathAndArchive(token));
    if (SetVars(filename))
    {
        // Create combined texture
        percent = ((TotalArea() * 100) / (out.w * out.h));
        printf("Total area consumed : %d%%\n", percent);
        printf("Texture resolution  : %dx%d pixels.\n", xcharsize, ycharsize);
        CreateMain();

        // Save image as m32
        sprintf (filename, "%spics/misc/%s.m32", gamedir, out.name);
        qtex32 = CreateMip32((unsigned *)outpixels, out.w, out.h, &size, false);

        qtex32->contents = 0;
        qtex32->value = 0;
        qtex32->scale_x = 1.0;
        qtex32->scale_y = 1.0;
        sprintf (qtex32->name, "misc/%s", out.name);

        printf ("\n\nwriting %s\n", filename);
        SaveFile (filename, (byte *)qtex32, size);
        free (qtex32);

        // Save out script file
        sprintf (filename, "%spics/misc/%s.fnt", gamedir, outscript);
        printf("Writing %s as script file\n", filename);
        if (!SaveScript(filename))
        {
            printf("Unable to save output script.\n");
        }
    }
    printf("Everythings groovy.\n");
    Cleanup();
}
Beispiel #5
0
//------------------------------------------------------------------------------
void GmatSavePanel::OnSaveAs(wxCommandEvent &event)
{
   #ifdef DEBUG_SAVE
   MessageInterface::ShowMessage
      ("GmatSavePanel::OnSaveAs() entered, script = '%s', mIsScriptActive = %d\n",
       mFilename.c_str(), mIsScriptActive);
   #endif
   
   wxFileDialog dialog(this, _T("Choose a file"), _T(""), _T(""),
         _T("Script files (*.script, *.m)|*.script;*.m|"\
            "Text files (*.txt, *.text)|*.txt;*.text|"\
            "All files (*.*)|*.*"), wxSAVE);
   
   bool saveScript = false;
   if (dialog.ShowModal() == wxID_OK)
   {
      wxString path = dialog.GetPath().c_str();
	  mSaveCanceled = false;
      
      if(DoesFileExist(path.c_str()))
      {
         if (wxMessageBox(_T("File already exists.\nDo you want to overwrite?"), 
                          _T("Please confirm"), wxICON_QUESTION | wxYES_NO) == wxYES)
         {
            mFilename = path;
            saveScript = true;
         }
		 else
			mSaveCanceled = true;
      }
      else
      {
         mFilename = path;
         saveScript = true;
      }
   }
   else
      mSaveCanceled = true;
   
   if (saveScript)      
      SaveScript();
   
   #ifdef DEBUG_SAVE
   MessageInterface::ShowMessage
      ("GmatSavePanel::OnSaveAs() leaving, saveScript=%d, mSaveCanceled=%d, script = '%s'\n",
       saveScript, mSaveCanceled, mFilename.c_str());
   #endif
}
/*!
 * Returns \a true if the application is ready to start with other script. Otherwise,
 * returns \a false.
 */
bool CodeEditorWidget::OkToContinue()
{

	QTextDocument* document = codeEditor->document();

	if ( document->isModified () )
	{
		int answer = QMessageBox::warning( this, tr( "Tonatiuh" ),
		                 tr( "The document has been modified.\n"
		                     "Do you want to save your changes?"),
		                 QMessageBox::Yes | QMessageBox::Default,
		                 QMessageBox::No,
		                 QMessageBox::Cancel | QMessageBox::Escape );

		if ( answer == QMessageBox::Yes ) return SaveScript();
		else if ( answer == QMessageBox::Cancel ) return false;
	}
	return true;
}
void __fastcall TfrmSearch::menuNewScriptClick(TObject *Sender)
{
  if(SkyEdit2->Modified)
  {
    switch(MessageBox(Handle,"是否保存所做的修改?","问题",MB_ICONWARNING | MB_YESNOCANCEL))
    {
    case IDYES:
      if(!SaveScript())
        return;
      break;
    case IDNO:
      break;
    default:
      return;
    }
  }
  SkyEdit2->Text    = "";
  CurScriptFileName = "";
  labScriptFile->Caption = "新的查询脚本";
  SkyEdit2->Modified = false;  
}
Beispiel #8
0
//------------------------------------------------------------------------------
void GmatSavePanel::OnSave(wxCommandEvent &event)
{
   // scriptStatus: 1 = clean, 2 = dirty, 3 = error
   int scriptStatus = theGuiManager->GetActiveScriptStatus();
   int guiStatus = theGuiManager->GetGuiStatus();
   
   #ifdef DEBUG_SAVE
   MessageInterface::ShowMessage
      ("GmatSavePanel::OnSave() entered, mSyncGui=%d, mFilename='%s'\n   tempFileName='%s', "
       "scriptStatus=%d, guiStatus=%d\n", mSyncGui, mFilename.c_str(),
       GmatAppData::Instance()->GetTempScriptName().c_str(), scriptStatus, guiStatus);
   #endif
   
   // If it is active script and both script and GUI is clean, there is nothing to save
   if (mIsScriptActive && scriptStatus == 1 && guiStatus == 1)
   {
      #ifdef DEBUG_SAVE
      MessageInterface::ShowMessage
         ("GmatSavePanel::OnSave() leaving, both script and GUI is clean\n",
          scriptStatus);
      #endif
      return;
   }
   
   mSaveCanceled = false;
   // if it is temp script file, call OnSaveAs() to bring up file dialog to save
   if (mFilename == GmatAppData::Instance()->GetTempScriptName())
   {
      OnSaveAs(event);
      if (mSaveCanceled)
      {
         #ifdef DEBUG_SAVE
         MessageInterface::ShowMessage
            ("GmatSavePanel::OnSave() leaving, user canceled SaveAs, mFilename='%s'\n", mFilename.c_str());
         #endif
         return;
      }
   }
   else if (!mSyncGui)
   {
      // Save inactive script and return
      SaveScript();
      mSyncGui = false;
      #ifdef DEBUG_SAVE
      MessageInterface::ShowMessage
         ("GmatSavePanel::OnSave() leaving, inactive script saved, mFilename='%s'\n", mFilename.c_str());
      #endif
      return;
   }
   
   // Confirm user if user wants to refresh GUI with script
   bool saveScript = false;
   if (guiStatus == 1)
   {
      saveScript = true;
   }
   // If GUI is dirty, prompt user to select an action
   else if (guiStatus == 2)
   {
      #ifdef DEBUG_SAVE
      MessageInterface::ShowMessage("   ==> Showing GUI overwrite confirm message\n");
      #endif
      wxString guiOverwriteMsg = "You will lose changes made in the GUI if the script "
         "is saved.  Do you want to save the script, discard the GUI changes, and reload "
         "the GUI with the saved script";
      if (event.GetEventObject() == mSaveSyncButton)
         guiOverwriteMsg = guiOverwriteMsg + "?";
      else if (event.GetEventObject() == mSaveSyncRunButton)
         guiOverwriteMsg = guiOverwriteMsg + " and run?";
      
      wxMessageDialog *msgDlg = new wxMessageDialog
         (this, guiOverwriteMsg, "Save script...",
          wxYES_NO | wxCANCEL |wxICON_QUESTION, wxDefaultPosition);
      
      int result = msgDlg->ShowModal();
      if (result == wxID_YES)
         saveScript = true;
      else
         mSyncGui = false;
      
      delete msgDlg;
   }
   
   #ifdef DEBUG_SAVE
   MessageInterface::ShowMessage
      ("   saveScript=%d, mSyncGui=%d\n", saveScript, mSyncGui);
   #endif
   
   if (saveScript)
      SaveAndBuildScript(event);
   
   #ifdef DEBUG_SAVE
   MessageInterface::ShowMessage
      ("GmatSavePanel::OnSave() leaving, mFilename='%s', mSyncGui=%d\n",
       mFilename.c_str(), mSyncGui);
   #endif
}
Beispiel #9
0
bool CSrScriptView::SaveCurrentScript (void)
{
	GetControlData();
	return SaveScript(m_pCurrentScript);
}