Пример #1
0
void CMagneticView::OnPlayback() 
{
  CMagneticApp* pApp = (CMagneticApp*)AfxGetApp();
  SimpleFileDialog PlayDlg(TRUE,NULL,m_strRecName,
    OFN_FILEMUSTEXIST|OFN_HIDEREADONLY|OFN_ENABLESIZING,
    "Record Files (*.rec)|*.rec|All Files (*.*)|*.*||",this);
  PlayDlg.m_ofn.lpstrTitle = "Play Back a File";

  switch (m_Recording)
  {
  case Recording::RecordingOff:
    if (ms_is_running())
      pApp->SetRedrawStatus(CMagneticApp::Redraw::ThisLine);
    if (PlayDlg.DoModal() == IDOK)
    {
      m_strRecName = PlayDlg.GetPathName();
      if ((m_pFileRecord = fopen(m_strRecName,"rt")) != NULL)
      {
        m_Recording = Recording::PlaybackOn;
        if (pApp->GetGameLoaded() && ms_is_running())
          pApp->SetRedrawStatus(CMagneticApp::Redraw::EndPlayback);
      }
    }
    break;
  case Recording::RecordingOn:
    break;
  case Recording::PlaybackOn:
    if (m_pFileRecord)
      fclose(m_pFileRecord);
    m_pFileRecord = NULL;
    m_Recording = Recording::RecordingOff;
    break;
  }
}
Пример #2
0
void CMagneticView::OnToggleGfx() 
{
  CMagneticApp* pApp = (CMagneticApp*)AfxGetApp();

  if (GetFocus() == this)
  {
    if (m_bMorePrompt == false)
    {
      switch (pApp->GetShowGraphics())
      {
      case CMagneticApp::ShowGraphics::NoGraphics:
        pApp->SetShowGraphics(CMagneticApp::ShowGraphics::SeparateWindow);
        break;
      case CMagneticApp::ShowGraphics::SeparateWindow:
        pApp->SetShowGraphics(CMagneticApp::ShowGraphics::MainWindow);
        break;
      case CMagneticApp::ShowGraphics::MainWindow:
        pApp->SetShowGraphics(CMagneticApp::ShowGraphics::NoGraphics);
        break;
      }
      pApp->SetRedrawStatus(CMagneticApp::Redraw::ThisLine);
      SetPictureWindowState();
    }
  }
}
Пример #3
0
void CMagneticView::OnScrollback() 
{
  CMagneticApp* pApp = (CMagneticApp*)AfxGetApp();

  pApp->SetRedrawStatus(CMagneticApp::Redraw::ThisLine);
  m_Scrollback.DoModal();
}
Пример #4
0
void CMagneticView::OnScript() 
{
  CMagneticApp* pApp = (CMagneticApp*)AfxGetApp();
  SimpleFileDialog ScriptDlg(FALSE,NULL,m_strScrName,OFN_HIDEREADONLY|OFN_ENABLESIZING,
    "Script Files (*.scr)|*.scr|All Files (*.*)|*.*||",this);
  ScriptDlg.m_ofn.lpstrTitle = "Scripting";

  switch (m_Scripting)
  {
  case Scripting::ScriptingOff:
    if (ms_is_running())
      pApp->SetRedrawStatus(CMagneticApp::Redraw::ThisLine);
    if (ScriptDlg.DoModal() == IDOK)
    {
      m_strScrName = ScriptDlg.GetPathName();
      if ((m_pFileScript = fopen(m_strScrName,"wt")) != NULL)
        m_Scripting = Scripting::ScriptingOn;
    }
    break;
  case Scripting::ScriptingOn:
    if (m_pFileScript)
      fclose(m_pFileScript);
    m_pFileScript = NULL;
    m_Scripting = Scripting::ScriptingOff;
    break;
  }
}
Пример #5
0
void CMagneticView::OnRecord() 
{
  CMagneticApp* pApp = (CMagneticApp*)AfxGetApp();
  SimpleFileDialog RecordDlg(FALSE,NULL,m_strRecName,OFN_HIDEREADONLY|OFN_ENABLESIZING,
    "Record Files (*.rec)|*.rec|All Files (*.*)|*.*||",this);
  RecordDlg.m_ofn.lpstrTitle = "Record Input File";

  switch (m_Recording)
  {
  case Recording::RecordingOff:
    if (ms_is_running())
      pApp->SetRedrawStatus(CMagneticApp::Redraw::ThisLine);
    if (RecordDlg.DoModal() == IDOK)
    {
      m_strRecName = RecordDlg.GetPathName();
      if ((m_pFileRecord = fopen(m_strRecName,"wt")) != NULL)
        m_Recording = Recording::RecordingOn;
    }
    break;
  case Recording::RecordingOn:
    if (m_pFileRecord)
      fclose(m_pFileRecord);
    m_pFileRecord = NULL;
    m_Recording = Recording::RecordingOff;
    break;
  case Recording::PlaybackOn:
    break;
  }
}
Пример #6
0
void CMagneticView::OnScrollback() 
{
  CMagneticApp* pApp = (CMagneticApp*)AfxGetApp();

  pApp->SetRedrawStatus(CMagneticApp::Redraw::ThisLine);
  AfxGetMainWnd()->GetWindowRect(m_Scrollback.GetRect());
  m_Scrollback.DoModal();
}
Пример #7
0
type8 ms_showhints(struct ms_hint * hints)
{
  CMagneticView* pView = CMagneticView::GetView();
  if (pView == NULL)
    return 0;

  CMagneticApp* pApp = (CMagneticApp*)AfxGetApp();
  if (pApp->GetUseHintWindow() == FALSE)
    return 0;
  if (ms_is_running())
     pApp->SetRedrawStatus(CMagneticApp::Redraw::ThisLine);
  pView->m_hintDlg.SetHints(hints);
  pView->m_hintDlg.DoModal();
  return 1;
}
Пример #8
0
void ms_fatal(type8s *txt)
{
  static bool InProgress = false;
  if (InProgress == false)
  {
    InProgress = true;
    
    CString Error;
    Error.Format("Magnetic has encountered an internal error:\n%s",txt ? (char*)txt : "");
    AfxGetMainWnd()->MessageBox(Error,"Internal Error",MB_ICONERROR|MB_OK);
    
    ms_stop();

    CMagneticApp* pApp = (CMagneticApp*)AfxGetApp();
    pApp->SetRedrawStatus(CMagneticApp::Redraw::EndOpcode);

    InProgress = false;
  }
}
Пример #9
0
type8 ms_load_file(type8s *name, type8 *ptr, type16 size)
{
  CMagneticApp* pApp = (CMagneticApp*)AfxGetApp();
  CString strLoadName;
  FILE *fh;

  if (name == NULL)
  {
    CMagneticView* pView = CMagneticView::GetView();
    if (pView == NULL)
      return 0;

    SimpleFileDialog LoadDlg(TRUE,NULL,pView->GetFileName(),
      OFN_FILEMUSTEXIST|OFN_HIDEREADONLY|OFN_ENABLESIZING,
      "Saved Game Files (*.sav)|*.sav|All Files (*.*)|*.*||",pView);
    LoadDlg.m_ofn.lpstrTitle = "Load a Saved Game";

    if (ms_is_running())
      pApp->SetRedrawStatus(CMagneticApp::Redraw::ThisLine);
    if (LoadDlg.DoModal() == IDOK)
    {
      strLoadName = LoadDlg.GetPathName();
      pView->GetFileName() = strLoadName;
    }
    else
      return 0;
  }
  else
    strLoadName = (char*)name;

  if ((fh = fopen(strLoadName,"rb")) == NULL)
    return 1;
  if (fread(ptr,1,size,fh) != size)
    return 1;
  fclose(fh);
  return 0;
}
Пример #10
0
BOOL CMagneticView::OpenGame(LPCTSTR lpszPathName)
{
  CMagneticApp* pApp = (CMagneticApp*)AfxGetApp();
  CMagneticView* pView = CMagneticView::GetView();

  if (pApp->GetGameLoaded() && ms_is_running())
    pApp->SetRedrawStatus(CMagneticApp::Redraw::EndOpcode);

  if (pView)
    pView->ClearAll();

  CString strGfxName, strHntName, strSndName;
  MakeFilePath(strGfxName,lpszPathName,".gfx");
  MakeFilePath(strHntName,lpszPathName,".hnt");
  MakeFilePath(strSndName,lpszPathName,".snd");

  // Free previous game
  ms_freemem();

  // Initialize new game
  pApp->SetGameLoaded(ms_init((type8s*)lpszPathName,
    (type8s*)((LPCTSTR)strGfxName),
    (type8s*)((LPCTSTR)strHntName),
    (type8s*)((LPCTSTR)strSndName)));

  // If required, make the random number generator predictable
  if (pApp->GetPredictable())
    ms_seed(pApp->GetRandomSeed());

  // Check status of loaded game
  if (pApp->GetGameLoaded() == 0)
  {
    CString strMessage;

    strMessage.Format("Failed to load game \"%s\"",lpszPathName);
    AfxMessageBox(strMessage,MB_ICONEXCLAMATION);
  }
  else
  {
    if (pView)
    {
      pView->m_bStatusBar = false;
      pView->Invalidate();
    }

    // Show the title picture, if possible
    CMagneticTitleDlg Title;
    Title.ShowTitle(lpszPathName);

    if (pView)
    {
      // Set up default file names
      MakeFilePath(pView->m_strRecName,lpszPathName,".rec");
      MakeFilePath(pView->m_strScrName,lpszPathName,".scr");
      MakeFilePath(pView->m_strFileName,lpszPathName,".sav");

      pView->m_bStatusBar = ms_is_magwin() ? false : true;
    }
  }

  if (pView)
    pView->Invalidate();
  return (pApp->GetGameLoaded() != 0) ? TRUE : FALSE;
}