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);
}
void ZGameWindow_Programmable::DisplayProgramName()
{
  ZStream_File Stream;
  ZString      FileName,FileSpec,File, Keyword, KeywordValue;
  FileName << (ULong)floor(RobotProgramNum.GetValue()) << ".nut";
  (FileSpec = GameEnv->Path_UserScripts_Squirrel).AddToPath(FileName);
  Stream.SetFileName(FileSpec.String);
  if (Stream.GetFileContent(File))
  {
    Keyword = "//";
    File.GetKeywordValue(&Keyword,KeywordValue);
    Text_ProgramName = KeywordValue;
    Text_ProgramName.StripLeading(' ');
    if (Text_ProgramName.Len > 60) Text_ProgramName.SetLen(60);
  }
  else Text_ProgramName.Clear();
  ProgramName.SetDisplayText(Text_ProgramName.String);
}
Пример #3
0
bool ZTest_Parts::RunTestCode()
{

  ZStream_File Stream;
  ZString Text;
  bool Result;

  ParsedRequest Pr;

  Stream.SetFileName("/home/laurent/workspace/a_newblackvoxel/Devdoc/Scratch_Request_Example.txt");
  Result = Stream.GetFileContent(Text);

  Pr.ParseRequest(Text);
  Pr.Dump();




  //Bmp.SetPixel()

//  ZTCPNet_Socket::Test();


  // ZHardwareInfo Hi;

  // Hi.DetectHardware();

  /*
  ZNet_SocketTest Test;

  Test.TestReceive();
  */
/*
  ZBitmapImage Bmp;
  long x,y;
  unsigned char xp,yp;
  ULong i;


  Bmp.CreateBitmap(512,256,32);
  Bmp.Clear();
  return(true);
  for (y=0;y<256;y++)
  {
    for (x=0;x<256;x++)
    {
      xp = x; yp =y;
      long v;
      v=x-y;
      if ( (v<0) || (v>255) )    Bmp.SetPixel(x,y,0,0,255,0);
      else                       Bmp.SetPixel(x,y,255,255,255,0);

      unsigned char vp;
      vp =xp-yp;
      if (vp>xp)  Bmp.SetPixel(x+256,y,0,0,255,0);
      else                          Bmp.SetPixel(x+256,y,255,255,255,0);

    }
  }

  for (i=0;i<256;i++)
  {
    Bmp.SetPixel(i,128,0,0,0,0);
    Bmp.SetPixel(128,i,0,0,0,0);
  }

  Bmp.SaveBMP("Out/test.bmp");
*/
  return(false);
}
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);
}