コード例 #1
0
Bool ZGameWindow_Programmable::MouseButtonClick  (UShort nButton, Short Absolute_x, Short Absolute_y)
{
  Bool Res;
  Res = ZFrame::MouseButtonClick(nButton, Absolute_x, Absolute_y);

  if (RobotProgramLoad.Is_MouseClick(true))
  {
    // VoxelExtension->SetScriptNum(floor(RobotProgramNum.GetValue()));
    VoxelExtension->CompileAndRunScript(ZVoxelExtension_Programmable::CONTEXT_PROGRAMCHANGE, floor(RobotProgramNum.GetValue()));
  }

  if (CloseBox.Is_MouseClick())
  {
    Hide();
  }

  if (RobotProgramNum.Is_MouseClick())
  {
    DisplayProgramName();
  }

  if (RobotProgramEdit.Is_MouseClick(true))
  {
    ZString FileName, FileSpec;

    FileName << (ULong)floor(RobotProgramNum.GetValue()) << ".nut";
    FileSpec = GameEnv->Path_UserScripts_Squirrel;
    FileSpec.AddToPath(FileName);

    // If the file does not exists, create it.

    if (!ZStream_File::File_IsExists(FileSpec.String))
    {
      ZString InFileSpec, Template;
      ZStream_File Stream;
      InFileSpec = GameEnv->Path_GameFiles;
      InFileSpec.AddToPath("Misc");
      InFileSpec.AddToPath("new_file_squirrel.nut");
      Stream.SetFileName(InFileSpec.String);
      Stream.GetFileContent(Template);
      Stream.SetFileName(FileSpec.String);
      Stream.PutFileContent(Template);
    }

    ZEditCode::EditCode(&GameEnv->Settings_Hardware->Setting_Favorite_Editor,&FileSpec);
  }

  return (Res);
}
コード例 #2
0
Bool ZGameWindow_ProgRobot_Asm::MouseButtonClick  (UShort nButton, Short Absolute_x, Short Absolute_y)
{
  Bool Res;
  Res = ZFrame::MouseButtonClick(nButton, Absolute_x, Absolute_y);

  if (RobotProgramLoad.Is_MouseClick(true))
  {
    // VoxelExtension->SetScriptNum(floor(RobotProgramNum.GetValue()));
    VoxelExtension->CompileAndRunScript(ZVoxelExtension_Programmable::CONTEXT_PROGRAMCHANGE, floor(RobotProgramNum.GetValue()));
  }

  if (RobotProgramDebug.Is_MouseClick(true))
  {
    if (VoxelExtension->CompileAndRunScript(ZVoxelExtension_Programmable::CONTEXT_PROGRAMCHANGE, floor(RobotProgramNum.GetValue()), true ))
    {
      //Hide();
      GameEnv->GuiManager.RemoveFrame(MainWindow);
      Flag_Shown = false;
      GameEnv->GameWindow_AsmDebug->SetVoxelExtension(VoxelExtension);
      GameEnv->GameWindow_AsmDebug->Show();
    }
    else
    {
      ZString ErrorMessage, ErrorExp, ErrorDetail;
      ZMacroAssembler::ZError * Error;
      ZMemSize Pos, Pos2, i;

      Error = VoxelExtension->Status.Error;

      if (!Error)
      {
        ErrorMessage  = "ERROR IN FILE";
        ErrorExp = " ";
      }
      else if (Error->CantLoadFile)
      {
        ErrorMessage  = "UNABLE TO READ PROGRAM FILE";
        ErrorExp = " ";
        ErrorDetail << Error->FileName;
      }
      else
      {
        //ErrorMessage = Error->ErrorMessage;
        ErrorDetail<< "ERROR : " << Error->ErrorMessage << "\n";
        ErrorDetail<< "WHERE : AT LINE " << (ULong)Error->Offset_ErrorLine << "\n";
        ErrorDetail<< "FILE  : " << Error->FileName << "\n\n";
        ErrorDetail<< "...............................ERROR DETAIL.............................\n\n";

        Pos = Error->Offset_ErrorLine;
        for (i=0;i<4;i++) Error->FileText.SearchPredLineStart(Pos);
        ErrorDetail.Append_Mids(&Error->FileText, Pos, Error->Offset_ErrorLine-1);
        ErrorDetail.Append_Mids(&Error->FileText, Error->Offset_ErrorLine, Error->Offset_ErrorStart - 1);
        ErrorDetail<<"~01:FF0000:[";
        ErrorDetail.Append_Mids(&Error->FileText, Error->Offset_ErrorStart, Error->Offset_ErrorEnd - 1);
        ErrorDetail<<"]~01:FFFFFF:";
        Pos = Error->Offset_ErrorEnd;
        Error->FileText.SearchNextLineStart(Pos);
        ErrorDetail.Append_Mids(&Error->FileText, Error->Offset_ErrorEnd,Pos-1);
        Pos2 = Pos;
        for (i=0;i<4;i++) Error->FileText.SearchNextLineStart(Pos2);
        ErrorDetail.Append_Mids(&Error->FileText, Pos, Pos2);

        //ErrorDetail.SearchReplace(' ', '.');
      }

      GameEnv->GameWindow_Compilation_Result->SetError(ErrorMessage.String, ErrorExp.String, ErrorDetail.String);
      GameEnv->GameWindow_Compilation_Result->Show();
    }

    //VoxelExtension->CompileAndRunScript(ZVoxelExtension_Programmable::CONTEXT_PROGRAMCHANGE, floor(RobotProgramNum.GetValue()));
  }

  if (RobotProgramDebugShow.Is_MouseClick(true))
  {
    if (VoxelExtension->IsAllowedToRun)
    {
      //Hide();
      GameEnv->GuiManager.RemoveFrame(MainWindow);
      Flag_Shown = false;
      GameEnv->GameWindow_AsmDebug->SetVoxelExtension(VoxelExtension);
      GameEnv->GameWindow_AsmDebug->Show();
    }

    //VoxelExtension->CompileAndRunScript(ZVoxelExtension_Programmable::CONTEXT_PROGRAMCHANGE, floor(RobotProgramNum.GetValue()));
  }

  if (CloseBox.Is_MouseClick(true))
  {
    Hide();
  }

  if (Manual.Is_MouseClick(true))
  {
    ZViewDoc::ViewDocPage(1585,false);
  }

  if (RobotProgramNum.Is_MouseClick())
  {
    DisplayProgramName();
  }

  if (RobotProgramEdit.Is_MouseClick(true))
  {
    ZString FileName, FileSpec;

    FileName << (ULong)floor(RobotProgramNum.GetValue()) << ".asm";
    FileSpec = GameEnv->Path_UserScripts_Asm_1;
    FileSpec.AddToPath(FileName);

    // If the file does not exists, create it.

    if (!ZStream_File::File_IsExists(FileSpec.String))
    {
      ZString InFileSpec, Template;
      ZStream_File Stream;
      InFileSpec = GameEnv->Path_GameFiles;
      InFileSpec.AddToPath("Misc");
      InFileSpec.AddToPath("new_file_asm1.tmasm");
      Stream.SetFileName(InFileSpec.String);
      Stream.GetFileContent(Template);
      Stream.SetFileName(FileSpec.String);
      Stream.PutFileContent(Template);
    }

    ZEditCode::EditCode(&GameEnv->Settings_Hardware->Setting_Favorite_Editor,&FileSpec);
  }


  return (Res);
}