Exemple #1
0
void WFXEdit::DoDataExchange(CDataExchange* pDX)
{
  wfx_header tmp;
  CString tmpstr;
  int i, j;
  long value;
  CButton *cb;

  memcpy(&tmp,&the_wfx.header,sizeof(wfx_header));
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(WFXEdit)
		// NOTE: the ClassWizard will add DDX and DDV calls here
	//}}AFX_DATA_MAP
  DDX_Text(pDX, IDC_RADIUS, the_wfx.header.srcurve);
  DDX_Text(pDX, IDC_FREQUENCY, the_wfx.header.frvar);
  DDX_Text(pDX, IDC_VOLUME, the_wfx.header.volvar);
  DDX_Text(pDX, IDC_FLAGS, the_wfx.header.flags);

  value = the_wfx.header.flags;
  j=1;
  for(i=0;i<5;i++)
  {
    if(boxids[i])
    {
      cb=(CButton *) GetDlgItem(boxids[i]);
      cb->SetCheck(!!(value&j));
    }
    j<<=1;
  }
  if(memcmp(&tmp,&the_wfx.header,sizeof(wfx_header)))
  {
    the_wfx.m_changed=true;
  }
  RefreshDialog();
}
Exemple #2
0
BOOL CProjEdit::OnInitDialog() 
{
  CString tmpstr, tmpstr1, tmpstr2;

	CDialog::OnInitDialog();
  RefreshDialog();
  //tooltips
  {
    m_tooltip.Create(this,TTS_NOPREFIX);
    m_tooltip.SetMaxTipWidth(200);
    m_tooltip.SetTipBkColor(RGB(240,224,160));
    
    m_tooltip.AddTool(GetDlgItem(IDCANCEL), IDS_CANCEL);
    tmpstr1.LoadString(IDS_LOAD);
    tmpstr2.LoadString(IDS_PRO);
    tmpstr.Format(tmpstr1, tmpstr2);
    m_tooltip.AddTool(GetDlgItem(IDC_LOAD), tmpstr);
    tmpstr1.LoadString(IDS_LOADEX);
    tmpstr.Format(tmpstr1, tmpstr2);
    m_tooltip.AddTool(GetDlgItem(IDC_LOADEX), tmpstr);
    tmpstr1.LoadString(IDS_SAVE);
    tmpstr.Format(tmpstr1, tmpstr2);
    m_tooltip.AddTool(GetDlgItem(IDC_SAVEAS), tmpstr);
    tmpstr1.LoadString(IDS_NEW);
    tmpstr.Format(tmpstr1, tmpstr2);
    m_tooltip.AddTool(GetDlgItem(IDC_NEW), tmpstr);
    tmpstr1.LoadString(IDS_CHECK);
    tmpstr.Format(tmpstr1, tmpstr2);
    m_tooltip.AddTool(GetDlgItem(IDC_CHECK), tmpstr);
  }	
	return TRUE;
}
Exemple #3
0
void CScriptEdit::OnNew() 
{
  NewScript();
  m_text_control.SetWindowText("");
  UpdateData(UD_DISPLAY);
  CheckScript(FORCED_CHECK|WHOLE_CHECK);
  RefreshDialog();
}
void KeepLastDialog::OnCheck2() 
{
	// TODO: Add your control notification handler code here
	m_checkuser=((CButton *) GetDlgItem(IDC_CHECK2))->GetCheck(); 
	RefreshDialog();
	
	
}
BOOL KeepLastDialog::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	// TODO: Add extra initialization here
	RefreshDialog();
	
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}
Exemple #6
0
BOOL CScriptEdit::OnInitDialog() 
{
  CFont Font;
  CString tmpstr,tmpstr1,tmpstr2;

  the_ids.new_ids();
  m_idsname="";
  if(editflg&INDENT) m_indent=2;
  else m_indent=4;
	CDialog::OnInitDialog();
  m_text_control.LimitText(MAX_SCRIPT_LEN);
  m_text_control.ModifyStyle(0,ES_SAVESEL);
  m_text_control.SetOptions(ECOOP_OR,ECO_AUTOWORDSELECTION|ECO_SAVESEL|ECO_WANTRETURN|ECO_NOHIDESEL);
  //enables the update event for a rich edit control
  m_text_control.SetEventMask(ENM_CHANGE|ENM_UPDATE|ENM_MOUSEEVENTS|ENM_KEYEVENTS|ENM_SCROLL|ENM_SELCHANGE);
  Font.CreateFont(15,0,0,0,0,0,0,0,0,0,0,0,0,"Courier New");
  m_text_control.SetFont(&Font);
  Font.DeleteObject();
//  UpdateData(UD_DISPLAY);
  CheckScript(WHOLE_CHECK|FORCED_CHECK);
  RefreshDialog();
  RefreshMenu();
  m_infind=0;
  //tooltips
  {
    m_tooltip.Create(this,TTS_NOPREFIX);
    m_tooltip.SetMaxTipWidth(200);
    m_tooltip.SetTipBkColor(RGB(240,224,160));
    
    m_tooltip.AddTool(GetDlgItem(IDCANCEL), IDS_CANCEL);
    tmpstr1.LoadString(IDS_LOAD);
    tmpstr2.LoadString(IDS_SCRIPT);
    tmpstr.Format(tmpstr1, tmpstr2);
    m_tooltip.AddTool(GetDlgItem(IDC_LOAD), tmpstr);
    tmpstr1.LoadString(IDS_LOADEX);
    tmpstr.Format(tmpstr1, tmpstr2);
    m_tooltip.AddTool(GetDlgItem(IDC_LOADEX), tmpstr);
    tmpstr1.LoadString(IDS_SAVE);
    tmpstr.Format(tmpstr1, tmpstr2);
    m_tooltip.AddTool(GetDlgItem(IDC_SAVEAS), tmpstr);
    tmpstr1.LoadString(IDS_NEW);
    tmpstr.Format(tmpstr1, tmpstr2);
    m_tooltip.AddTool(GetDlgItem(IDC_NEW), tmpstr);
    tmpstr1.LoadString(IDS_CHECK);
    tmpstr.Format(tmpstr1, tmpstr2);
    m_tooltip.AddTool(GetDlgItem(IDC_CHECK), tmpstr);
  }
	return TRUE;
}
Exemple #7
0
BOOL WFXEdit::OnInitDialog() 
{
	CDialog::OnInitDialog();
	RefreshDialog();	
  //tooltips
  {
    m_tooltip.Create(this,TTS_NOPREFIX);
    m_tooltip.SetMaxTipWidth(200);
    m_tooltip.SetTipBkColor(RGB(240,224,160));
    
    m_tooltip.AddTool(GetDlgItem(IDCANCEL), IDS_CANCEL);
  }	
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}
Exemple #8
0
BOOL CItemPicker::OnInitDialog() 
{
  CString tmp;
  CRect rect;

	CDialog::OnInitDialog();
  switch(m_restype)
  {
  case REF_ARE:
    the_2da.new_2da();
    read_2da("MAPNAME",the_2da);
    //falling through
  case REF_BMP:
  case REF_PLT:
  case REF_BAM:
  case REF_ITM:
  case REF_SPL:
  case REF_VVC:
  case REF_MOS:
  case REF_CHU:
    m_preview_control.ShowWindow(true);
    m_preview.Create(IDD_IMAGEVIEW,this);
    GetWindowRect(rect);
    m_preview.SetWindowPos(0,rect.right,rect.top,0,0,SWP_NOACTIVATE|SWP_NOZORDER|SWP_HIDEWINDOW|SWP_NOSIZE);
    break;
  case REF_WAV:
  case REF_ACM:
    m_play_control.ShowWindow(true);
    break;
  }
  if (m_restype==REF_BAM)
  {
    m_animlist_control.ShowWindow(true);
    m_resolve_control.ShowWindow(false);
  }
  RefreshDialog();
  m_pick_control.SelectString(0,m_picked);
  OnSelchangePick();
  //tooltips
  {
    m_tooltip.Create(this,TTS_NOPREFIX);
    m_tooltip.SetMaxTipWidth(200);
    m_tooltip.SetTipBkColor(RGB(240,224,160));
  }
  UpdateData(UD_DISPLAY);
  return TRUE;
}
Exemple #9
0
void CScriptEdit::OnChangeText() 
{
  CWnd *cwnd;

  cwnd=GetFocus();
  //make sure that the edit window has the input focus, otherwise this could
  //cause various unexpected bugs
//  if(!cwnd || (m_text_control.GetSafeHwnd()!=cwnd->GetSafeHwnd()) ) return;
  if(!cwnd || (cwnd->GetDlgCtrlID()!=IDC_TEXT) ) return;
  UpdateData(UD_RETRIEVE);
  if(m_text_control.GetModify())
  {
    the_script.m_changed=true;
  }
  CheckScript(FORCED_CHECK);
  RefreshDialog();
}
Exemple #10
0
void WFXEdit::OnLoadex() 
{
  int fhandle;
  int res;
  
  res=OFN_FILEMUSTEXIST|OFN_ENABLESIZING|OFN_EXPLORER;
  if(readonly) res|=OFN_READONLY;  
  CMyFileDialog m_getfiledlg(TRUE, "wfx", makeitemname(".wfx",0), res, szFilter);

restart:  
  //if (filepath.GetLength()) strncpy(m_getfiledlg.m_ofn.lpstrFile,filepath, filepath.GetLength()+1);
  if( m_getfiledlg.DoModal() == IDOK )
  {
    filepath=m_getfiledlg.GetPathName();
    fhandle=open(filepath, O_RDONLY|O_BINARY);
    if(!fhandle)
    {
      MessageBox("Cannot open file!","Error",MB_ICONSTOP|MB_OK);
      goto restart;
    }
    readonly=m_getfiledlg.GetReadOnlyPref();
    res=the_wfx.ReadWFXFromFile(fhandle,-1);
    close(fhandle);
    lastopenedoverride=filepath.Left(filepath.ReverseFind('\\'));
    switch(res)
    {
    case 0:
      itemname=m_getfiledlg.GetFileTitle();
      itemname.MakeUpper();
      break;
    default:
      MessageBox("Cannot read wave effect!","Error",MB_ICONSTOP|MB_OK);
      NewWFX();
      break;
    }
  }
  RefreshDialog();
  UpdateData(UD_DISPLAY);
}
Exemple #11
0
void WFXEdit::OnLoad() 
{
	int res;
	
  pickerdlg.m_restype=REF_WFX;
  pickerdlg.m_picked=itemname;
	res=pickerdlg.DoModal();
	if(res==IDOK)
	{
		res=read_wfx(pickerdlg.m_picked);
    switch(res)
    {
    case 0:
  		itemname=pickerdlg.m_picked;
      break;
    default:
      MessageBox("Cannot read wave effect!","Error",MB_ICONSTOP|MB_OK);
      NewWFX();
      break;
    }
	}
  RefreshDialog();
  UpdateData(UD_DISPLAY);
}
Exemple #12
0
void CScriptEdit::OnSetfocusText() 
{
  if(!m_firsterror) CheckScript(0);
  RefreshDialog();	
}
void FotaFullscreenDialog::SetWarningDetails(TFotaWarningType aType)
    {
    FLOG(_L("FotaFullscreenDialog::SetWarningDetails <<"));
    //set heading content
    if (aType == EHbFotaDownload)
        {
        FLOG(_L("FotaFullscreenDialog::EHbFotaDownload"));
        idialog->setTimeout(HbPopup::NoTimeout);
        iInstallNote = qobject_cast<HbLabel *> (iloader.findWidget(
                    "lblinstallnote"));
        iInstallNote->setPlainText(hbTrId(
                    "txt_device_update_info_installation_will_proceed_n"));
        //User::After(1000);
        iInstallNote->setVisible(false);
        
        iRestartNote = qobject_cast<HbLabel *> (iloader.findWidget(
                    "lblRestartNote"));
        iRestartNote->setPlainText(hbTrId(
                    "txt_device_update_info_FS_after_the_installation_the"));
        //User::After(1000);
        iRestartNote->setVisible(false);
        
        iRestartIcon = qobject_cast<HbLabel *> (iloader.findWidget("icnInstall"));
        HbIcon iconRestart;
        //iconRestart.setIconName(:/icons/qgn_prop_sml_http.svg);
        //iRestartIcon->setIcon(iconRestart);
        //User::After(1000);
        iRestartIcon->setVisible(false);
        
        iEmergencyNote = qobject_cast<HbLabel *> (iloader.findWidget(
                    "lblEmergency"));
        iEmergencyNote->setPlainText(hbTrId(
                   "txt_device_update_info_FS_during_the_installation_the"));
        //User::After(1000);
        iEmergencyNote->setVisible(false);
        
        iEmergencyIcon = qobject_cast<HbLabel *> (iloader.findWidget(
                    "icnEmergency"));
        HbIcon iconEmergency;
        //iconEmergency.setIconName(:/icons/qgn_prop_sml_http.svg);
        //iEmergencyIcon->setIcon(iconEmergency);
        //User::After(1000);
        iEmergencyIcon->setVisible(false);

        }
    else if (aType == EHbFotaUpdate)
        {
        FLOG(_L("FotaFullscreenDialog::EHbFotaUpdate"));
        idialog->setTimeout(HbPopup::ContextMenuTimeout);
        HbIcon iconCharger;
        //iconCharger.setIconName(:/icons/qgn_prop_sml_http.svg);
        //iChargerIcon->setIcon(iconCharger);
        HbIcon iconRestart;
        //iconRestart.setIconName(:/icons/qgn_prop_sml_http.svg);
        //iRestartIcon->setIcon(iconRestart);
        iInstallNote->setPlainText(hbTrId(
                "txt_device_update_info_installation_will_proceed_n"));
        iChargerNote->setPlainText(hbTrId(
                "txt_device_update_info_FS_its_recommended_to_connec"));
        iRestartNote->setPlainText(hbTrId(
                "txt_device_update_info_FS_after_the_installation_the"));
        iInstallNote->setVisible(true);
        iRestartNote->setVisible(true);
        iRestartIcon->setVisible(true);
        iEmergencyNote->setVisible(true);
        iEmergencyIcon->setVisible(true);
        iDownloadState->setPlainText(hbTrId(
                "txt_device_update_info_download_complete"));
        iDownloadState->setVisible(true);
        iPrimaryAction->setEnabled(ETrue);
        }
    else if (aType == EHbFotaLowBattery)
        {
        FLOG(_L("FotaFullscreenDialog::EHbFotaLowBattery"));
        idialog->setTimeout(HbPopup::NoTimeout);
        HbIcon iconCharger;
        //iconCharger.setIconName(:/icons/qgn_prop_sml_http.svg);
        //iChargerIcon->setIcon(iconCharger);
        HbIcon iconRestart;
        //iconRestart.setIconName(:/icons/qgn_prop_sml_http.svg);
        //iRestartIcon->setIcon(iconRestart);
        iInstallNote->setPlainText(hbTrId(
                "txt_device_update_info_to_proceed_with_installatio"));
        iChargerNote->setPlainText(hbTrId(
                "txt_device_update_info_FS_after_the_installation_the"));
        iRestartNote->setPlainText(hbTrId(
                "txt_device_update_info_FS_during_the_installation_the"));
        //iEmergencyNote->setPlainText(hbTrId("txt_device_update_info_FS_during_the_installation_the"));
        iInstallNote->setVisible(true);
        iRestartNote->setVisible(true);
        iRestartIcon->setVisible(true);
        iEmergencyNote->setVisible(false);
        iEmergencyIcon->setVisible(false);
        iDownloadState->setPlainText(hbTrId(
                "txt_device_update_info_download_complete"));
        iDownloadState->setVisible(true);
        iPrimaryAction->setText(hbTrId("txt_device_update_button_continue"));
        iSecondaryAction->setText(hbTrId(
                "txt_device_update_button_install_later"));
        iPrimaryAction->setEnabled(EFalse);
        }
    RefreshDialog();
    FLOG(_L("FotaFullscreenDialog::SetWarningDetails >>"));
    }
Exemple #14
0
void CScriptEdit::OnSaveasGeneral(int type) 
{
  char BASED_CODE *szFilter;
  CString tmpstr;
  CString newname;
  int fhandle;
  int res;

  if(readonly)
  {
    MessageBox("You opened it read only!","Warning",MB_ICONEXCLAMATION|MB_OK);
    return;
  }
  res=OFN_HIDEREADONLY|OFN_ENABLESIZING|OFN_EXPLORER;

  if(type!=-1) m_bcs=type;
  szFilter=szFilterb;
  if(m_bcs)
  {
    //szFilter=szFiltera;
    tmpstr=bgfolder+"override\\"+itemname;
  }
  else
  {
    //szFilter=szFilterb;    
    tmpstr=makeitemname(".baf",1);
  }
  CMyFileDialog m_getfiledlg(FALSE, m_bcs?"bcs":"baf", tmpstr, res, szFilter);
  m_getfiledlg.m_ofn.nFilterIndex = m_bcs+1;

restart:  
  if( m_getfiledlg.DoModal() == IDOK )
  {
    filepath=m_getfiledlg.GetPathName();
    filepath.MakeLower();
    if(filepath.Right(4)==".baf") m_bcs=0;
    else if(filepath.Right(4)==".bcs") m_bcs=1; //this is the default
    if(m_bcs)
    {
      if(filepath.Right(4)!=".bcs")  filepath+=".bcs";
      lastopenedoverride=filepath.Left(filepath.ReverseFind('\\'));
    }
    else
    {
      if(filepath.Right(4)!=".baf")  filepath+=".baf";
      lastopenedscript=filepath.Left(filepath.ReverseFind('\\'));
    }
    newname=m_getfiledlg.GetFileName();
    newname.MakeUpper();
    if(newname.Right(4)==".BCS") newname=newname.Left(newname.GetLength()-4);
    else if(newname.Right(4)==".BAF") newname=newname.Left(newname.GetLength()-4);
    if(newname.GetLength()>8 || newname.GetLength()<1 || newname.Find(" ",0)!=-1)
    {
      tmpstr.Format("The resource name '%s' is wrong, it should be 8 characters long and without spaces.",newname);
      MessageBox(tmpstr,"Warning",MB_ICONEXCLAMATION|MB_OK);
      goto restart;
    }
    if(newname!=itemname && file_exists(filepath) )
    {
      res=MessageBox("Do you want to overwrite "+newname+"?","Warning",MB_ICONQUESTION|MB_YESNO);
      if(res==IDNO) goto restart;
    }
    
    itemname=newname;
    res=0;
    if(filepath.Right(4)==".bcs")
    {
      chdir(bgfolder);
      tmpstr=bgfolder+weidudecompiled;
      assure_dir_exists(tmpstr);
      if(!dir_exists(tmpstr) )
      {
        res=-3;
      }
      else tmpstr+="\\"+newname+".baf";
    }
    if(!res)
    {
      fhandle=creat(tmpstr,S_IWRITE);
      if(fhandle>0)
      {
        //this is the intended way of extracting info from a richedit control
        res=writestream(fhandle,m_text_control);
        close(fhandle);
      }
      else res=-2;
      if(m_bcs)
      {
        if(!res) res=compile(tmpstr);
      }
    }
    switch(res)
    {
    case -3:
      newname.Format("Cannot create output path:%s",tmpstr);
      MessageBox(tmpstr,"Script editor",MB_ICONSTOP|MB_OK);
      break;
    case -2:
      newname.Format("Cannot create  file:%s",tmpstr);
      MessageBox(tmpstr,"Script editor",MB_ICONSTOP|MB_OK);
      break;
    case 0:
      if(m_bcs) MessageBox("Script saved and compiled...","Script editor",MB_ICONINFORMATION|MB_OK);
      else MessageBox("Script saved...","Script editor",MB_ICONINFORMATION|MB_OK);
      break;
    default:
      MessageBox("Error during save.","Script editor",MB_ICONSTOP|MB_OK);
    }
  }
  UpdateData(UD_DISPLAY);
  the_script.m_changed=false;
  CheckScript(0);
  RefreshDialog();
}
Exemple #15
0
void CItemPicker::OnResolve() 
{
	editflg^=RESOLVE;
  RefreshDialog();
}
FotaFullscreenDialog::FotaFullscreenDialog(CFotaServer* aObserver)
    {
    FLOG(_L("FotaFullscreenDialog::FotaFullscreenDialog >>"));
    bool ok = false;
    iServer = aObserver;
    iloader.load(":/xml/data/fullscreendialog.docml", &ok);
    if (!ok)
        {
        return;
        }
    iClicked = EFalse;
    idialog = qobject_cast<HbDialog *> (iloader.findWidget("dialog"));

	idialog->setTimeout(HbPopup::NoTimeout);
   
    iPrimaryAction = qobject_cast<HbPushButton *> (iloader.findWidget(
            "btnHide"));
			
     iSecondaryAction = qobject_cast<HbPushButton *> (iloader.findWidget(
            "btnResumeLater"));
			
			
    
    iprogressBar = qobject_cast<HbProgressBar *> (iloader.findWidget(
            "horizontalProgressBar"));
    iprogressBar->setProgressValue(0);
	
	    /*iInstallNote = qobject_cast<HbLabel *> (iloader.findWidget(
            "lblinstallnote"));*/
    iDownloadState = qobject_cast<HbLabel *> (iloader.findWidget(
            "lblDownloadState"));
    //iEmergencyIcon = qobject_cast<HbLabel *> (iloader.findWidget(
    //        "icnEmergency"));
    iChargerIcon = qobject_cast<HbLabel *> (iloader.findWidget("icnCharger"));
    HbIcon iconCharger;
    //iconCharger.setIconName(:/icons/qgn_prop_sml_http.svg);
    //iChargerIcon->setIcon(iconCharger);
    HbIcon iconEmergency;
    //iconEmergency.setIconName(:/icons/qgn_prop_sml_http.svg);
    //iEmergencyIcon->setIcon(iconEmergency);
    //iEmergencyNote = qobject_cast<HbLabel *> (iloader.findWidget(
    //        "lblEmergency"));
    //iRestartIcon = qobject_cast<HbLabel *> (iloader.findWidget("icnInstall"));
    //HbIcon iconRestart;
    //iconRestart.setIconName(:/icons/qgn_prop_sml_http.svg);
    //iRestartIcon->setIcon(iconRestart);
    //iRestartNote = qobject_cast<HbLabel *> (iloader.findWidget(
    //        "lblRestartNote"));
    //installEventFilter(this);
    iPrimaryAction->setText(hbTrId("txt_common_button_hide"));
    iSecondaryAction->setText(hbTrId("txt_device_update_button_resume_later"));
    iTitle = qobject_cast<HbLabel *> (iloader.findWidget("lblTitle"));
    iTitle->setPlainText(hbTrId("txt_device_update_title_updating_phone"));
    iDownloadState->setPlainText(hbTrId("txt_device_update_info_downloading"));
    //iInstallNote->setPlainText(hbTrId(
    //        "txt_device_update_info_installation_will_proceed_n"));
    iChargerNote = qobject_cast<HbLabel *> (iloader.findWidget("lblcharger"));
    iChargerNote->setPlainText(hbTrId(
            "txt_device_update_info_FS_its_recommended_to_connec"));
    //iRestartNote->setPlainText(hbTrId(
    //        "txt_device_update_info_FS_after_the_installation_the"));
    //iEmergencyNote->setPlainText(hbTrId(
    //        "txt_device_update_info_FS_during_the_installation_the"));

    QObject::connect(iPrimaryAction, SIGNAL(clicked()), this,
            SLOT(LSKSelected()));
    QObject::connect(iSecondaryAction, SIGNAL(clicked()), this,
            SLOT(RSKSelected()));
    QObject::connect(idialog, SIGNAL(aboutToClose()), this,
            SLOT(aboutToClose()));

    RefreshDialog();
    FLOG(_L("FotaFullscreenDialog::FotaFullscreenDialog <<"));
    }
void FotaFullscreenDialog::SetVisible(TBool aVisible)
{
    FLOG(_L("RefreshDialog::SetVisible >>"));
    RefreshDialog();
    FLOG(_L("RefreshDialog::SetVisible <<"));
}
Exemple #18
0
void WFXEdit::SaveWFX(int save) 
{
  CString newname;
  CString tmpstr;
  int res;

  if(readonly)
  {
    MessageBox("You opened it read only!","Warning",MB_ICONEXCLAMATION|MB_OK);
    return;
  }
  res=OFN_HIDEREADONLY|OFN_ENABLESIZING|OFN_EXPLORER;
  CMyFileDialog m_getfiledlg(FALSE, "wfx", makeitemname(".wfx",0), res, szFilter);

  if(save)
  {
    newname=itemname;
    filepath=makeitemname(".wfx",0);
    goto gotname;
  }    
  
restart:  
  //if (filepath.GetLength()) strncpy(m_getfiledlg.m_ofn.lpstrFile,filepath, filepath.GetLength()+1);
  if( m_getfiledlg.DoModal() == IDOK )
  {
    filepath=m_getfiledlg.GetPathName();
    filepath.MakeLower();
    if(filepath.Right(4)!=".wfx")
    {
      filepath+=".wfx";
    }
    newname=m_getfiledlg.GetFileName();
    newname.MakeUpper();
    if(newname.Right(4)==".WFX") newname=newname.Left(newname.GetLength()-4);
gotname:
    if(newname.GetLength()>8 || newname.GetLength()<1 || newname.Find(" ",0)!=-1)
    {
      tmpstr.Format("The resource name '%s' is bad, it should be 8 characters long and without spaces.",newname);
      MessageBox(tmpstr,"Warning",MB_ICONEXCLAMATION|MB_OK);
      goto restart;
    }
    if(newname!=itemname && file_exists(filepath) )
    {
      res=MessageBox("Do you want to overwrite "+newname+"?","Warning",MB_ICONQUESTION|MB_YESNO);
      if(res==IDNO) goto restart;
    }
    
    res = write_wfx(newname, filepath);
    lastopenedoverride=filepath.Left(filepath.ReverseFind('\\'));
    switch(res)
    {
    case 0:
      itemname=newname;
      break; //saved successfully
    case -2:
      MessageBox("Error while writing file!","Error",MB_ICONSTOP|MB_OK);
      break;
    case -3:
      MessageBox("Internal Error!","Error",MB_ICONSTOP|MB_OK);
      break;
    default:
      MessageBox("Unhandled error!","Error",MB_ICONSTOP|MB_OK);
    }
  }
  RefreshDialog();
  UpdateData(UD_DISPLAY);
}
Exemple #19
0
void CScriptEdit::OnLoad() 
{
  CString filepath;
  CString m_text;
  int fhandle;
	int res;
  char *pos;
	
  pickerdlg.m_restype=REF_BCS;
  pickerdlg.m_picked=itemname;
	res=pickerdlg.DoModal();
	if(res==IDOK)
	{
    filepath=pickerdlg.m_picked+".bcs";
    itemname=pickerdlg.m_picked;
    m_bcs=1;
		res=decompile(filepath, itemname); //this will decompile the bcs
    if(res)
    {
      MessageBox("Cannot decompile file!","Error",MB_OK);
    }
    else
    {
      fhandle=open(filepath, O_RDONLY|O_BINARY);
      if(!fhandle)
      {
        MessageBox("Cannot open file!","Error",MB_OK);
        res=-1;
      }
      if(!res) 
      {//fhandle will always get initialized if res was 0
        res=filelength(fhandle);
        if(res>=0)
        {
          pos=m_text.GetBufferSetLength(res);
          if(pos)
          {
            if(read(fhandle,pos,res)!=res) res=-1;
            else res=0;
          }
          else res=-1;
          m_text.ReleaseBuffer();
          m_text_control.SetWindowText(m_text);
        }
        close(fhandle);
      }
    }
    switch(res)
    {
    case 0:
      if((m_bcs==1) && (editflg&REMBAF) )
      {//removing decompiled baf
        unlink(filepath);
      }
      break;
    default:
      MessageBox("Cannot read script!","Error",MB_OK);
      OnNew();
      return;
    }
	}
  UpdateData(UD_DISPLAY);
  the_script.m_changed=false;
  CheckScript(WHOLE_CHECK|FORCED_CHECK);
  RefreshDialog();
}
Exemple #20
0
void WFXEdit::OnNew() 
{
	NewWFX();
  RefreshDialog();
  UpdateData(UD_DISPLAY);
}
Exemple #21
0
void CScriptEdit::OnLoadex() 
{
  char BASED_CODE *szFilter;
  CString m_text;
  CString fpath;
  int fhandle;
  int res;
  char *pos;
  
  res=OFN_FILEMUSTEXIST|OFN_ENABLESIZING|OFN_EXPLORER;
  if(readonly) res|=OFN_READONLY;
  szFilter=szFilterb;
  CMyFileDialog m_getfiledlg(TRUE, m_bcs?"bcs":"baf", m_bcs ? makeitemname(".bcs",0): makeitemname(".baf",1), res, szFilter);
  m_getfiledlg.m_ofn.nFilterIndex = m_bcs+1;

  if( m_getfiledlg.DoModal() == IDOK )
  {
    filepath = fpath = m_getfiledlg.GetPathName();
    if(checkfile(fpath,"SC") )
    {
      m_bcs=1;
      res=decompile(filepath, m_getfiledlg.GetFileTitle()); //decompile first
      if(res)
      {
        MessageBox("Cannot decompile file: "+fpath+"!","Error",MB_OK);
        return;
      }
      lastopenedoverride=fpath.Left(filepath.ReverseFind('\\'));
    }
    else
    { //remember the path when opening a script source 
      m_bcs=0;
      lastopenedscript=fpath.Left(filepath.ReverseFind('\\'));
    }
    fhandle=open(filepath, O_RDONLY|O_BINARY);
    if(fhandle<1)
    {
      MessageBox("Cannot open file!","Error",MB_OK);
      return;
    }
    readonly=m_getfiledlg.GetReadOnlyPref();
    res=filelength(fhandle);
    if(res>=0)
    {
      pos=m_text.GetBufferSetLength(res);
      if(pos)
      {
        if(read(fhandle,pos,res)!=res) res=-9;
        else res=0;
      }
      else res=-9;
    }
    m_text.ReleaseBuffer();
    close(fhandle);
    m_text_control.SetWindowText(m_text);
    switch(res)
    {
    case 0:
      if((m_bcs==1) && (editflg&REMBAF) )
      {//removing decompiled baf
        unlink(filepath);
      }
      itemname=m_getfiledlg.GetFileTitle();
      itemname.MakeUpper();
      break;
    case -9: //special error: cannot read decompiled script
      MessageBox("Cannot read script!","Error",MB_OK);
    default: //that error was already handled elsewhere
      OnNew();
      return;
    }
  }
  UpdateData(UD_DISPLAY);
  the_script.m_changed=false;
  CheckScript(WHOLE_CHECK|FORCED_CHECK);
  RefreshDialog();
}