Exemplo n.º 1
0
Arquivo: xmodem.c Projeto: phire/pimon
void xmodem_init() {
	addCommand("rx", &rx);
}
Exemplo n.º 2
0
void cMenu::addTilePic( uint32_t x, uint32_t y, uint32_t tile, uint32_t hue )
{
	addCommand( "{tilepic %d %d %d %d}", x, y, tile, hue );
}
Exemplo n.º 3
0
void cMenu::addCheckbox( uint32_t x, uint32_t y, uint32_t off, uint32_t on, uint32_t checked, int32_t result )
{
	rc_checkbox.insert( make_pair( result, rc_serialCurrent ) );
	addCommand( "{checkbox %d %d %d %d %d %d}", x, y, off, on, checked, rc_serialCurrent++ );
}
Exemplo n.º 4
0
void cMenu::addCheckertrans( uint32_t x, uint32_t y, uint32_t width, uint32_t height )
{
	addCommand( "{checkertrans %d %d %d %d}", x, y, width, height );
}
Exemplo n.º 5
0
void cMenu::addText( uint32_t x, uint32_t y, unistring data, uint32_t hue )
{
	addCommand( "{text %d %d %d %d}", x, y, hue, addString(data) ); //text <Spaces from Left> <Space from top> <Length, Color?> <# in order>
}
Exemplo n.º 6
0
void cMenu::addGump( uint32_t x, uint32_t y, uint32_t gump, uint32_t hue )
{
	addCommand( "{gumppic %d %d %d hue=%d}", x, y, gump, hue );
}
Exemplo n.º 7
0
void cMenu::addHtmlGump( uint32_t x, uint32_t y, uint32_t width, uint32_t height, unistring html, uint32_t hasBack, uint32_t canScroll )
{
	addCommand( "{htmlgump %d %d %d %d %d %d %d}", x, y, width, height, addString(html), hasBack, canScroll );
}
Exemplo n.º 8
0
void PyQtProjectItem::installCommands()
{
    // get plugins
    CLIToolPlugin* ip = interpreter();
    
    // temp command
    pCommand cmd;

    // build command
    if ( ip ) {
        cmd = ip->command();
    }
    
    cmd.setProject( this );
    cmd.setSkipOnError( false );
    const pCommand cmdInterpret = cmd;
    
    // available commands
    if ( ip ) {
        // execute project
        cmd = cmdInterpret;
        cmd.setName( "run" );
        cmd.setText( tr( "Run" ) );
        cmd.setCommand( QString( "%1 $target$" ).arg( cmd.command() ) );
        cmd.setParsers( QStringList() );
        cmd.setTryAllParsers( false );
        addCommand( "mInterpreter", cmd );
    }
    
    pyQtBinaryFilePath( PyQtProjectItem::Python );
    
    // pyuic4 on current file
    cmd = cmdInterpret;
    cmd.setName( "generate_form" );
    cmd.setText( tr( "Generate current form implementation" ) );
    cmd.setCommand( QString( "%1 $cf$ -o $cf$.py" ).arg( pyQtBinaryFilePath( PyQtProjectItem::Uic ) ) );
    cmd.setWorkingDirectory( "$cfp$" );
    cmd.setParsers( QStringList() );
    cmd.setSkipOnError( false );
    cmd.setTryAllParsers( false );
    addCommand( "mInterpreter", cmd );
    
    // pyrcc4 on current file
    cmd = cmdInterpret;
    cmd.setName( "generate_resource" );
    cmd.setText( tr( "Generate current resource implementation" ) );
    cmd.setCommand( QString( "%1 $cf$ -o $cf$.py" ).arg( pyQtBinaryFilePath( PyQtProjectItem::Rcc ) ) );
    cmd.setWorkingDirectory( "$cfp$" );
    cmd.setParsers( QStringList() );
    cmd.setSkipOnError( false );
    cmd.setTryAllParsers( false );
    addCommand( "mInterpreter", cmd );
    
    // pylupdate4 on current source file
    cmd = cmdInterpret;
    cmd.setName( "update_translation" );
    cmd.setText( tr( "Update current source translation file" ) );
    cmd.setCommand( QString( "%1 $cf$ -ts translations.ts" ).arg( pyQtBinaryFilePath( PyQtProjectItem::LUpdate ) ) );
    cmd.setWorkingDirectory( "$cpp$" );
    cmd.setParsers( QStringList() );
    cmd.setSkipOnError( false );
    cmd.setTryAllParsers( false );
    addCommand( "mInterpreter", cmd );
    
    // lrelease on current file
    cmd = cmdInterpret;
    cmd.setName( "generate_translation" );
    cmd.setText( tr( "Generate current translation qm file" ) );
    cmd.setCommand( QString( "%1 $cf$ -qm translation.qm" ).arg( pyQtBinaryFilePath( PyQtProjectItem::LRelease ) ) );
    cmd.setWorkingDirectory( "$cpp$" );
    cmd.setParsers( QStringList() );
    cmd.setSkipOnError( false );
    cmd.setTryAllParsers( false );
    addCommand( "mInterpreter", cmd );
    
    // install defaults commands
    XUPProjectItem::installCommands();
}
Exemplo n.º 9
0
void Renderer::addCommand(RenderCommand* command)
{
    int renderQueue =_commandGroupStack.top();
    addCommand(command, renderQueue);
}
Exemplo n.º 10
0
Scheduler::Scheduler(Command *masterCommand) {
  addCommand(masterCommand);
}
Exemplo n.º 11
0
void KPrDocument::removePages(QList<KoPAPageBase *> &pages)
{
    KPrDeleteSlidesCommand *command = new KPrDeleteSlidesCommand(this, pages);
    addCommand(command);
}
Exemplo n.º 12
0
command_stream* evaluatePostfix(token* finalTokenStream)
{
	/*
	notes on structures and types declared above
	typedef enum
	{
		WORD_TOKEN, //ls foo
		SEMICOLON_TOKEN, // ;
		PIPE_TOKEN, // |
		AND_TOKEN, // &&
		OR_TOKEN, // ||
		LEFT_PAREN_TOKEN, // ( //not relevant at this point
		RIGHT_PAREN_TOKEN, // )//not relevant at this point
		GREATER_TOKEN, // >
		LESS_TOKEN, // <
		NEWLINE_TOKEN, // \n //not relevant at this point
		NULL_TOKEN, // //not relevant at this point
	} tokentype;
	
	enum command_type
	{
		AND_COMMAND,         // A && B
		SEQUENCE_COMMAND,    // A ; B
		OR_COMMAND,          // A || B
		PIPE_COMMAND,        // A | B
		SIMPLE_COMMAND,      // a simple command
		SUBSHELL_COMMAND,    // ( A )
	};
	  
	typedef struct command_stream
	{
		struct command_stream* next;
		struct command_stream* prev;
		struct command* root;
		
	} command_stream;
	
	struct command
	{
		command* prev;
		command* next; //for linked list before tree conversion
		enum command_type type;
		// Exit status, or -1 if not known (e.g., because it has not exited yet).
		int status;
		// I/O redirections, or 0 if none.
		char *input;
		char *output;
		union
		{
			// for AND_COMMAND, SEQUENCE_COMMAND, OR_COMMAND, PIPE_COMMAND:
			struct command *command[2];
			// for SIMPLE_COMMAND:
			char **word;
			// for SUBSHELL_COMMAND:
			struct command *subshell_command;
		} u;
	};
	*/
	command* cmd_start = NULL;
	command* cmd_end = NULL;
	
	command_stream* str_start = NULL;
	command_stream* str_end = NULL;
	
	command_stream* firststream = malloc(sizeof(command_stream));
	addStream(&str_start, &str_end, firststream);
	
	token* curr;
	for (curr = finalTokenStream; curr != NULL; curr = curr->next)
		if (curr->t == WORD_TOKEN) //add simple command to command stack
		{
			command* newcommand = malloc(sizeof(command));
			newcommand->type = SIMPLE_COMMAND;
			newcommand->status = -1;
			newcommand->input = newcommand->output = 0;
			newcommand->u.word = curr->words;
			if (curr->prev && curr->prev->sub > 1 && curr->sub == 1) //if we just ended a subshell, then make what was there a subshell command on itself
			{
				command* prevcmd = malloc(sizeof(command));
				prevcmd->type = SUBSHELL_COMMAND;
				prevcmd->input = prevcmd->output = 0;
				prevcmd->status = -1;
				prevcmd->u.subshell_command = popCommand(&cmd_start, &cmd_end);
				addCommand(&cmd_start, &cmd_end, prevcmd);
			}
			
			addCommand(&cmd_start, &cmd_end, newcommand);
		}
		else if (curr->t == SEMICOLON_TOKEN && curr->sub == 1) //stop working on the current stream and instead make a new stream if no subshell, otherwise make a sequence command
		{
			if (curr->prev && curr->prev->sub > 1) //if we just ended a subshell, then make cmd_start a subshell command on itself
			{
				command* newcommand = malloc(sizeof(command));
				newcommand->type = SUBSHELL_COMMAND;
				newcommand->input = newcommand->output = 0;
				newcommand->status = -1;
				newcommand->u.subshell_command = cmd_start;
				cmd_start = newcommand;
			}
			str_end->root=cmd_start;
			cmd_start = cmd_end = NULL;
			command_stream* newstream = malloc(sizeof(command_stream));
			addStream(&str_start, &str_end, newstream);
		}
		else if (curr->t == LESS_TOKEN || curr->t == GREATER_TOKEN) //change the input based on what command you are redirecting
		{
			//remove two last commands and make them a subtree with correct depth level and add subtree back to command list
			command* dest = popCommand(&cmd_start, &cmd_end); //where to redirect
			command* operation = popCommand(&cmd_start, &cmd_end); //what to do, assume always simple command
			
			command* newcommand = malloc(sizeof(command));
			newcommand->type = SIMPLE_COMMAND;
			newcommand->status = -1;
			if (curr->t == LESS_TOKEN)
			{
				newcommand->input = concat(dest->u.word[0], dest->u.word[1]);
				newcommand->output= operation->output;
			}
			else
			{
				newcommand->output= concat(dest->u.word[0], dest->u.word[1]);
				newcommand->input = operation->input;
			}
			newcommand->u.word = operation->u.word;
			addCommand(&cmd_start, &cmd_end, newcommand);
		}
		else //an operation that needs to be made into a tree
		{
			command* operand2 = popCommand(&cmd_start, &cmd_end), *operand1 = popCommand(&cmd_start, &cmd_end);
			
			if ((curr->prev && curr->prev->sub > 1 && curr->sub == 1) || operand2->type == SEQUENCE_COMMAND) //if we just ended a subshell, then make operand2 a subshell command on itself
			{
				command* newcommand = malloc(sizeof(command));
				newcommand->type = SUBSHELL_COMMAND;
				newcommand->input = newcommand->output = 0;
				newcommand->status = -1;
				newcommand->u.subshell_command = operand2;
				operand2 = newcommand;
			}
			if (operand1->type == SEQUENCE_COMMAND) //convert operand1 into subshell if it was a sequence, as sequences are only possible in subshells
			{
				command* newcommand = malloc(sizeof(command));
				newcommand->type = SUBSHELL_COMMAND;
				newcommand->input = newcommand->output = 0;
				newcommand->status = -1;
				newcommand->u.subshell_command = operand1;
				operand1 = newcommand;
			}
			command* newcommand = malloc(sizeof(command));
			newcommand->type = tokenToCommandType(curr->t);
			newcommand->status = -1;
			newcommand->input = newcommand->output = 0;
			newcommand->u.command[0] = operand1;
			newcommand->u.command[1] = operand2;
			addCommand(&cmd_start, &cmd_end, newcommand);
		}
	
	str_end->root=cmd_start;
	
	return str_start;
}
Exemplo n.º 13
0
command_stream_t
make_command_stream (int (*get_next_byte) (void *),
		     void *get_next_byte_argument)
{
  if ( DEBUG == 1 )
    printf("make_command_stream: Starting!\n");
  //create return command_stream
  struct command_stream *c_stream = (struct command_stream *) checked_malloc(sizeof(struct command_stream));
  //read line from script
  char *c_line = (char *) checked_malloc(sizeof(char *) * SIZE_BUFFER);
  c_line = pullBytes(*get_next_byte, get_next_byte_argument);

  //create token list and initialize to NULL
  struct token_list *t_list = (struct token_list *) checked_malloc(sizeof(struct token_list));
  t_list->start = NULL;
  t_list->end = NULL;

  int c_line_pos = 0;
  int start_pos = 0;
  int num_lines = 1;
  int num_parens = 0;
  bool new_word = false;
  bool line_empty = true;
  bool line_ignore = false;
  bool line_NULL = true;
  bool special_token_finished = false;


  while( c_line != NULL )
  {
    if ( DEBUG == 1 )
      printf("make_command_stream: current line:%d contents: %s\n", num_lines, c_line);
    line_NULL = false;
    while ( true )
    {
      //check if line is a comment or null byte and go to next lin
      if ( c_line[0] == '#' || c_line[0] == '\0')
      {
        num_lines++;
        line_ignore = true;
        break;
      }
      //check for special tokens
      if ( specialToken(c_line[c_line_pos]) )
      {
        if ( DEBUG == 1 )
          printf("make_command_stream: is special token\n");
        if ( c_line_pos == 0 && c_line[c_line_pos] != '(' )
          printError(num_lines);
        if ( new_word )
        {
          char *word_string = getString(c_line, start_pos, c_line_pos-1);
          struct token *new_token = (struct token *) checked_malloc(sizeof(struct  token));
          new_token->word = word_string;
          new_token->next = NULL;
          addToken(new_token, t_list);
          if ( DEBUG == 1 )
          {
            printf("make_command_stream: new token added\n");
          }
        }
        start_pos = c_line_pos;
        //make special token to add to list
        struct token *token_special = (struct token *) checked_malloc(sizeof(struct token));
        token_special->next = NULL;
        // OR "||" operator and PIPE '|' operator
        if ( c_line[c_line_pos] == '|' ) //PIPE token
        {
          if ( c_line[c_line_pos + 1] == '|' ) // OR token
          {
            token_special->word = getString(c_line, start_pos, c_line_pos + 1);
            if ( DEBUG == 1 )
              printf("make_command_stream: added token is OR operator\n");
            c_line_pos += 2;
          }
          else
          {
            if ( DEBUG == 1 )
              printf("make_command_stream: token is PIPE operator\n");
            token_special->word = getString(c_line, start_pos, c_line_pos);
            c_line_pos++;
          }
          special_token_finished = true;
        }
        else if ( c_line[c_line_pos] == '&' )
        {
          if ( c_line[c_line_pos + 1] == '&' )
          {
            token_special->word = getString(c_line, start_pos, c_line_pos + 1);
            c_line_pos += 2;
            special_token_finished = true;
            if ( DEBUG == 1 )
              printf("make_command_stream: token is AND operator\n");
          } 
          else
            printError(num_lines);
        }
        else if ( c_line[c_line_pos] == '(' )
        {
          token_special->word = getString(c_line, start_pos, c_line_pos);
          num_parens++;
          if ( DEBUG == 1 )
            printf("make_command_stream: added token is LEFT_PAREN operator\n");
          c_line_pos++;
          special_token_finished = true;
        }
        else if ( c_line[c_line_pos] == ')' )
        {
          num_parens--;
          if ( num_parens == 0 )
            special_token_finished = false;
          else
            special_token_finished = true;
          if ( num_parens < 0 )
            printError(num_lines);
          token_special->word = getString(c_line, start_pos, c_line_pos);
          if ( DEBUG == 1 )
            printf("make_command_stream: added token is a RIGHT_PAREN operator\n");
          c_line_pos++;
        }
        else if ( c_line[c_line_pos] == ';' )
        {
          if ( DEBUG == 1 )
            printf("make_command_stream: added token is a SEMI operator\n");
          token_special->word = getString(c_line, start_pos, c_line_pos);
          special_token_finished = false;
          c_line_pos++;
        }
        else 
        {
          token_special->word = getString(c_line, start_pos, c_line_pos);
          c_line_pos++;
          if ( DEBUG == 1 )
            printf("make_command_stream: added token is a %s operator", token_special->word);
        }
        start_pos = c_line_pos;
        addToken(token_special, t_list);
        new_word = false;
        line_empty = false;
      }
      else //not a special token
      {
        if ( validWord(c_line[c_line_pos]) || c_line[c_line_pos] == ' ' )
        {
          if ( c_line[c_line_pos] != ' ' )
            if ( new_word == false )
            {
              new_word = true;
              line_empty = false;
            }
        }
        else
        {
          printError(num_lines);
        }
        c_line_pos++;
      }
      if ( c_line[c_line_pos] == '#' || c_line[c_line_pos] == '\0' )
      {
        if ( new_word )
        {
          char *word_string = getString(c_line, start_pos, c_line_pos - 1);
          struct token *token_simple = (struct token *) checked_malloc(sizeof(struct token));
          token_simple->word = word_string;
          token_simple->next = NULL;
          addToken(token_simple, t_list);
          special_token_finished = false;
          line_empty = false;
        }
        if ( (c_line[c_line_pos] == '\0' && special_token_finished) || (num_parens > 0) || line_empty) 
        {
          if ( DEBUG == 1 )
            printf("make_command_stream: Last token reached\n");
          line_ignore = true;
          if ( num_parens > 0 ) //newline in between sub-shell commands
          {
            struct token *semi_token = (struct token *) checked_malloc(sizeof(struct token));
            semi_token->next = NULL;
            char *s_colon = (char *) checked_malloc(sizeof(char *) * 2);
            s_colon[0] = ';';
            s_colon[1] = '\0';
            semi_token->word = s_colon;
            addToken(semi_token, t_list);
            if ( DEBUG == 1 )
              printf("make_command_stream: semi colon token created from newline\n");
          }
        }
        break;
      }
    }
    if ( DEBUG == 1 )
    {
      printf("make_command_stream: Tokens created and put into t_list\n");
      int i = 0;
      struct token *t_list_h = t_list->start;
      struct token *t_list_t = t_list->end;
      while ( t_list->start != NULL )
      {
        printf("make_command_stream: Word %d:%s\n", i, t_list->start->word);
        t_list->start = t_list->start->next;
        i++;
      }
      t_list->start = t_list_h;
      t_list->end = t_list_t;
      printf("\n\n");
    }
    // c_line is not empty/ignored
    if ( line_ignore == false )
    {
      struct node_list *n_list = tokensToNodes(t_list);
      if ( n_list == NULL )
        printError(num_lines);
      // create stack tree from our node list and add command
      struct command *command_root = create_stack_tree(n_list);
      if ( command_root == NULL )
      {
        if ( DEBUG == 1 )
          printf("make_command_stream: command_root is NULL\n");
        printError(num_lines);
      }
      addCommand(c_stream, command_root);
    }
    free(c_line);
    c_line = pullBytes(*get_next_byte, get_next_byte_argument);
    num_lines++;
    c_line_pos = 0;
    start_pos = 0;
    new_word = false;
    line_ignore = false;
    line_empty = true;
    line_NULL = true;
    if ( DEBUG == 1 )
    printf("make_command_stream: Iterations completed\n");
  }
  if ( num_parens > 0 && line_NULL )
  {
    printError(num_lines);
  }
  if ( special_token_finished && line_NULL )
  {
    printError(num_lines);
  }
  if ( DEBUG == 1 )
    printf("make_command_stream: Reached end of function\n");
  return c_stream;
}
Exemplo n.º 14
0
void TestController::addConsoleAutoTest()
{
    auto console = Director::getInstance()->getConsole();
    
    static struct Console::Command autotest = {
        "autotest", 
        "testcpp autotest command, use -h to list available tests", 
        [](int fd, const std::string& args) 
        {
            Scheduler *sched = Director::getInstance()->getScheduler();
            if(args == "help" || args == "-h")
            {
                const char msg[] = "usage: autotest ActionsTest\n\tavailable tests: ";
                send(fd, msg, sizeof(msg),0);
                send(fd, "\n",1,0);
                for(int i = 0; i < g_testCount; i++)
                {
                    send(fd, "\t",1,0);
                    send(fd, g_aTestNames[i].test_name, strlen(g_aTestNames[i].test_name)+1,0);
                    send(fd, "\n",1,0);
                }
                const char help_main[] = "\tmain, return to main menu\n";
                send(fd, help_main, sizeof(help_main),0);

                const char help_next[] = "\tnext, run next test\n";
                send(fd, help_next, sizeof(help_next),0);
                
                const char help_back[] = "\tback, run prev test\n";
                send(fd, help_back, sizeof(help_back),0);
                
                const char help_restart[] = "\trestart, restart current test\n";
                send(fd, help_restart, sizeof(help_restart),0);
                return;
            }
            if(args == "main")
            {
                
                sched->performFunctionInCocosThread( [&]()
                {
                    auto scene = Scene::create();
                    auto layer = new TestController();
                    scene->addChild(layer);
                    layer->release();
                    Director::getInstance()->replaceScene(scene);
                    cocostudio::ArmatureDataManager::destroyInstance();
                } );
                return;
            }
            const char msg_notest[] = "autotest: can't detect running test.\n";
            AppDelegate* app = (AppDelegate *)Application::getInstance();
            BaseTest* currentTest = app->getCurrentTest();
            if(args == "next")
            {
                if(currentTest != nullptr)
                {
                    //currentTest->nextCallback(nullptr);
                    sched->performFunctionInCocosThread( [&](){
                            currentTest->nextCallback(nullptr);
                        } );
                }
                else
                {
                    send(fd, msg_notest, sizeof(msg_notest),0);
                }
                return;
            }
            if(args == "back")
            {
                if(currentTest != nullptr)
                {
                    sched->performFunctionInCocosThread( [&](){
                        currentTest->backCallback(nullptr);
                    } );
                }
                else
                {
                    send(fd, msg_notest, sizeof(msg_notest),0);
                }
                return;
            }

            if(args == "restart")
            {
                if(currentTest != nullptr)
                {
                    sched->performFunctionInCocosThread( [&](){
                        currentTest->restartCallback(nullptr);
                    } );
                }
                else
                {
                    send(fd, msg_notest, sizeof(msg_notest),0);
                }
                return;
            }

            if(args == "run")
            {
                for (int i = 0; i < g_testCount; i++)
                {
                    // create the test scene and run it
                    std::string  msg("autotest: running test:");
                    msg += g_aTestNames[i].test_name;
                    send(fd, msg.c_str(), strlen(msg.c_str()),0);
                    send(fd, "\n",1,0);

                    currentController = &g_aTestNames[i];
                    sched->performFunctionInCocosThread( [&](){
                        auto scene = currentController->callback();
                        if(scene)
                        {
                            scene->runThisTest();
                            scene->release();
                        }
                    } );
                    wait(1);
                    BaseTest* firstTest = app->getCurrentTest();
                    if(firstTest == nullptr)
                    {
                        continue;
                    }
                    std::string  t1("");
                    t1 += firstTest->subtitle();
                    send(fd, t1.c_str(), strlen(t1.c_str()),0);
                    send(fd, "\n",1,0);
                    wait(2);

                    while(1)
                    {
                        //currentTest->nextCallback(nullptr);
                        sched->performFunctionInCocosThread( [&](){
                            BaseTest *t = app->getCurrentTest();
                            if(t != nullptr)
                            {
                                t->nextCallback(nullptr);
                            }
                        } );
                        wait(1);
                        BaseTest * curTest = app->getCurrentTest();
                        if(curTest == nullptr)
                        {
                            break;
                        }
                        std::string  title("");
                        title += curTest->subtitle();
                        send(fd, title.c_str(), strlen(title.c_str()),0);
                        send(fd, "\n",1,0);
                        wait(2);

                        if(t1 == title)
                        {
                            break;
                        }
                    }
                }
                std::string  msg("autotest run successfully!");
                send(fd, msg.c_str(), strlen(msg.c_str()),0);
                send(fd, "\n",1,0);
                return;
            }

            for(int i = 0; i < g_testCount; i++)
            {
                if(args == g_aTestNames[i].test_name)
                {
                    currentController = &g_aTestNames[i];
                    std::string  msg("autotest: running test:");
                    msg += args;
                    send(fd, msg.c_str(), strlen(msg.c_str()),0);
                    send(fd, "\n",1,0);

                        
                    sched->performFunctionInCocosThread( [&](){
                        auto scene = currentController->callback();
                        if(scene)
                        {
                            scene->runThisTest();
                            scene->release();
                        }
                    } );
                    return;
                }
            }

            //no match found,print warning message
            std::string  msg("autotest: could not find test:");
            msg += args;
            send(fd, msg.c_str(), strlen(msg.c_str()),0);
            send(fd, "\n",1,0);
        }
        
    };
    console->addCommand(autotest);
}
Exemplo n.º 15
0
HProject::HProject()
{
	// TODO: is it appropriate to add commands in the constructor or should they be registered somewhere else?
	addCommand(new CProjectCreateClass());
}
Exemplo n.º 16
0
void KoEnhancedPathShape::addCommand( const QString &command )
{
    addCommand( command, true );
}
Exemplo n.º 17
0
void cMenu::addButton( uint32_t x, uint32_t y, uint32_t up, uint32_t down, int32_t returnCode, bool pressable )
{
	rc_button.insert( make_pair( rc_serialCurrent, returnCode ) );
	addCommand( "{button %d %d %d %d %d %d %d}", x, y, up, down, pressable, pageCurrent, rc_serialCurrent++ );
}
Exemplo n.º 18
0
//Does the assembly code verification, counting the instructions and data number.
int checksAssembly()
{
    FILE *file = NULL;
    char *line;
    char aux[300];

    //Number of lines
    int lineNumber = 1;
    //Counts the program lines(only instructions, directives and labels)
    int lineCount = 0;
    //Tells which part of the reader program is
    int module = 0, end = 0, pseg = 0, dseg = 0;
    //Save the directive code
    int directiveCode = -2;

    int instructionState = 0;

    file = fopen(urlInputFile, "r");

    while(fgets(aux, sizeof(aux), file)!= NULL)
    {
        //Verifies the line
        line = verifyLine(aux);

        //If is anything
        if(line!=NULL)
        {
            //Reads the directive code
            directiveCode = getDirective(line);

            //Asserts that the first instructions are the .module
            if(lineCount == 0 && directiveCode != 0){
                informError(1, lineNumber);
                fclose(file);
                return 1;
            }
            //If is .module
            if(directiveCode == 0){
                module = 1;
                end = 0;
            }
            //If is .pseg
            else if(directiveCode == 1){
                pseg = 1;
                dseg = 0;
            }
            //If is .dseg
            else if(directiveCode == 2){
            	if(pseg == 0){
            		informError(6, lineNumber);
            		fclose(file);
                	return 1;
				}
                pseg = 0;
                dseg = 1;
            }
            //If is .end
            else if(directiveCode == 4){
                module = 0;
                end = 1;
                lineCount = 0;
            }

            //If is a wrong directive
            else if(directiveCode == -2){
                informError(3, lineNumber);
                fclose(file);
                return 1;
            }

            //If is a instruction increments the number of instruction
            if(pseg == 1 && module == 1 && line[0] != '.' && directiveCode != 3){
                addCommand(line, lineNumber);
                numberOfInstructions++;
            }

            else if(pseg == 1 && module == 1 && line[0] == '.' && directiveCode == 3){
                informError(4, lineNumber);
                fclose(file);
                return 1;
            }

            //If is a word increments the number of instruction
            if(dseg == 1 && module == 1 && directiveCode == 3){
                addCommand(line, lineNumber);
                numberOfData++;
            }

            else if(dseg == 1 && module == 1 && directiveCode == -1){
                informError(5, lineNumber);
                fclose(file);
                return 1;
            }

            //Checks if the memory(64KB -> 16384 32-bits address) was exceeded
            if((numberOfData + numberOfInstructions) > 16384){
                informError(2, lineNumber);
                fclose(file);
                return 1;
            }

            if(end != 1)
                lineCount++;
        }
        lineNumber++;
    }
    fclose(file);
    return 0;
}
Exemplo n.º 19
0
void cMenu::addTiledGump( uint32_t x, uint32_t y, uint32_t width, uint32_t height, uint32_t gump, uint32_t hue )
{
	addCommand( "{gumppictiled %d %d %d %d %d %d}", x, y, width, height, gump, hue );
}
Exemplo n.º 20
0
Sprite *HelloWorld::spriteWithColor1(Color4F color1, Color4F color2, float texWidth, float texHeight, int nStripes)
{
    RenderTexture *rt = RenderTexture::create(texWidth, texHeight);
    rt->beginWithClear(color1.r, color1.g, color1.b, color1.a);
    
    // 3: Draw into the texture
    // You'll add this later
    
    setGLProgramState(cocos2d::GLProgramState::getOrCreateWithGLProgramName(cocos2d::GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR_NO_MVP));
    
    
    _customCommand.init(_globalZOrder);
    _customCommand.func = [texWidth, texHeight, nStripes, color2, this]() {
        Vec2 *vertices = new Vec2[6*nStripes];
        Color4F *colors = new Color4F[6*nStripes];
        
        int nVertices = 0;
        float x1 = -texHeight;
        float x2;
        float y1 = texHeight;
        float y2 = 0;
        float dx = texWidth / nStripes * 2;
        float stripeWidth = dx/2;
        for (int i=0; i<nStripes; i++) {
            x2 = x1 + texHeight;
            
            vertices[nVertices] = Vec2 {x1, y1};
            colors[nVertices++] = Color4F{color2.r, color2.g, color2.b, color2.a};
            
            vertices[nVertices] = Vec2 {x1+stripeWidth, y1};
            colors[nVertices++] = Color4F {color2.r, color2.g, color2.b, color2.a};
            
            vertices[nVertices] = Vec2 {x2, y2};
            colors[nVertices++] = Color4F {color2.r, color2.g, color2.b, color2.a};
            
            vertices[nVertices] = vertices[nVertices-2];
            colors[nVertices++] = Color4F {color2.r, color2.g, color2.b, color2.a};
            
            vertices[nVertices] = vertices[nVertices-2];
            colors[nVertices++] = Color4F {color2.r, color2.g, color2.b, color2.a};
            
            vertices[nVertices] = Vec2 {x2+stripeWidth, y2};
            colors[nVertices++] = Color4F {color2.r, color2.g, color2.b, color2.a};
            x1 += dx;
        }
        
        getGLProgram()->use();
        getGLProgram()->setUniformsForBuiltins();
        
        cocos2d::GL::enableVertexAttribs(cocos2d::GL::VERTEX_ATTRIB_FLAG_POSITION | cocos2d::GL::VERTEX_ATTRIB_FLAG_COLOR);
        
//        glBindBuffer(GL_ARRAY_BUFFER, 0);
        glVertexAttribPointer(cocos2d::GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, vertices);
        glVertexAttribPointer(cocos2d::GLProgram::VERTEX_ATTRIB_COLOR, 4, GL_FLOAT, GL_TRUE, 0, colors);
        glDrawArrays(GL_TRIANGLES, 0, (GLsizei)nVertices);
        
        float gradientAlpha = 0.7f;
        nVertices = 0;
        
        vertices[nVertices] = Vec2 {0, 0};
        colors[nVertices++] = Color4F {0, 0, 0, 0 };
        vertices[nVertices] = Vec2 {texWidth, 0};
        colors[nVertices++] = Color4F {0, 0, 0, 0};
        vertices[nVertices] = Vec2 {0, texHeight};
        colors[nVertices++] = Color4F {0, 0, 0, gradientAlpha};
        vertices[nVertices] = Vec2 {texWidth, texHeight};
        colors[nVertices++] = Color4F {0, 0, 0, gradientAlpha};
        
        glVertexAttribPointer(cocos2d::GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, vertices);
        glVertexAttribPointer(cocos2d::GLProgram::VERTEX_ATTRIB_COLOR, 4, GL_FLOAT, GL_FALSE, 0, colors);

//        glBlendFunc(CC_BLEND_SRC, CC_BLEND_DST);
        cocos2d::GL::blendFunc(CC_BLEND_SRC, CC_BLEND_DST);
        glDrawArrays(GL_TRIANGLE_STRIP, 0, (GLsizei)nVertices);
        
        
        // layer 3: top highlight
        float borderHeight = texHeight/16;
        float borderAlpha = 0.3f;
        nVertices = 0;
        
        vertices[nVertices] = Vec2 {0, 0};
        colors[nVertices++] = Color4F {1, 1, 1, borderAlpha};
        
        vertices[nVertices] = Vec2 {texWidth, 0};
        colors[nVertices++] = Color4F {1, 1, 1, borderAlpha};
        
        vertices[nVertices] = Vec2 {0, borderHeight};
        colors[nVertices++] = Color4F {0, 0, 0, 0};
        
        vertices[nVertices] = Vec2 {texWidth, borderHeight};
        colors[nVertices++] = Color4F {0, 0, 0, 0};
        
        glVertexAttribPointer(cocos2d::GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, vertices);
        glVertexAttribPointer(cocos2d::GLProgram::VERTEX_ATTRIB_COLOR, 4, GL_FLOAT, GL_FALSE, 0, colors);
        glBlendFunc(CC_BLEND_SRC, CC_BLEND_DST);
        glDrawArrays(GL_TRIANGLE_STRIP, 0, (GLsizei)nVertices);
        
        CC_SAFE_DELETE_ARRAY(vertices);
        CC_SAFE_DELETE_ARRAY(colors);
        
    };
    
    auto renderer = Director::getInstance()->getRenderer();
    renderer->addCommand(&_customCommand);
    
    Sprite *noise = Sprite::create("Noise-iphone5hd.png");
    noise->setBlendFunc(BlendFunc {GL_DST_COLOR, GL_ZERO});
    noise->setPosition(texWidth/2, texHeight/2);
    noise->visit();
    
    rt->end();
    
    return Sprite::createWithTexture(rt->getSprite()->getTexture());

}
Exemplo n.º 21
0
void cMenu::addXmfHtmlGump( uint32_t x, uint32_t y, uint32_t width, uint32_t height, unistring clilocid, uint32_t hasBack , uint32_t canScroll )
{
	addCommand( "{xmfhtmlgump %d %d %d %d %s %d %d}", x, y, width, height, addString(clilocid), hasBack, canScroll );
}
Exemplo n.º 22
0
QxPreferences::QxPreferences(Ref<CharcoalDirectory> charcoalDirectory, QWidget* parent)
	: QxDialog(parent),
	  charcoalDirectory_(charcoalDirectory),
	  themeManager_(charcoalDirectory->themeManager()),
	  paletteManager_(charcoalDirectory->paletteManager())
{
	setWindowTitle(qApp->applicationName() + " - Preferences");
	#ifdef Q_WS_MAC
	#ifndef QT_MAC_USE_COCOA
	setAttribute(Qt::WA_MacShowFocusRect, false);
	#endif // QT_MAC_USE_COCOA
	#endif // Q_WS_MAC
	
	QGridLayout* grid = new QGridLayout(this);
	{
		tabs_ = new QTabWidget(this);
		tabs_->setElideMode(Qt::ElideNone);
		tabs_->setUsesScrollButtons(false);
		grid->addWidget(tabs_, 0, 0);
		// grid->setMargin(12);
	}
	
	{
		editor_ = new QxEditorPreferences(tabs_);
		tabs_->insertTab(tabs_->count(), editor_, tr("Editor"));
		
		editor_->fontSize_->setRange(8, 32);
		editor_->lineSpacing_->setRange(0, 32);
		editor_->tabWidth_->setRange(2, 32);
		editor_->indentWidth_->setRange(1, 32);
		
		connect(editor_->tabIndentMode_, SIGNAL(toggled(bool)), editor_->indentWidth_, SLOT(setDisabled(bool)));
		editor_->tabIndentMode_->setChecked(true);
		
		connect(editor_->font_, SIGNAL(currentFontChanged(const QFont&)), this, SLOT(updateEditorFontOption(const QFont&)));
		connect(editor_->fontSize_, SIGNAL(valueChanged(int)), this, SLOT(updateEditorIntOption(int)));
		connect(editor_->fontAntialiasing_, SIGNAL(toggled(bool)), this, SLOT(updateEditorBoolOption(bool)));
		connect(editor_->subpixelAntialiasing_, SIGNAL(toggled(bool)), this, SLOT(updateEditorBoolOption(bool)));
		connect(editor_->lineSpacing_, SIGNAL(valueChanged(int)), this, SLOT(updateEditorIntOption(int)));
		connect(editor_->showLineNumbers_, SIGNAL(toggled(bool)), this, SLOT(updateEditorBoolOption(bool)));
		connect(editor_->showWhitespace_, SIGNAL(toggled(bool)), this, SLOT(updateEditorBoolOption(bool)));
		connect(editor_->tabWidth_, SIGNAL(valueChanged(int)), this, SLOT(updateEditorIntOption(int)));
		
		connect(editor_->autoIndent_, SIGNAL(toggled(bool)), this, SIGNAL(editorAutoIndentChanged(bool)));
		connect(editor_->tabIndentMode_, SIGNAL(toggled(bool)), this, SLOT(updateEditorIndent(bool)));
		connect(editor_->indentWidth_, SIGNAL(valueChanged(int)), this, SLOT(updateEditorIndent(int)));
	}
	
	{
		terminal_ = new QxTerminalPreferences;
		tabs_->insertTab(tabs_->count(), terminal_, tr("Terminal"));
		
		terminal_->fontSize_->setRange(8, 32);
		terminal_->lineSpacing_->setRange(0, 32);
		terminal_->numberOfLines_->setRange(100000, 1000000);
		terminal_->numberOfLines_->setSingleStep(100000);
		terminal_->title_->addItems(
			QString(
				"$TITLE,"
				"$FG,"
				"$USER@$HOST,"
				"$USER@$FQHOST,"
				"$USER@$HOST:$CWD,"
				"$FG [$USER@$HOST],"
				"$FG [$USER@$HOST]:$CWD"
			).split(",")
		);
		terminal_->title_->setCurrentIndex(5);
		
		connect(terminal_->font_, SIGNAL(currentFontChanged(const QFont&)), this, SLOT(updateTerminalFontOption(const QFont&)));
		connect(terminal_->fontSize_, SIGNAL(valueChanged(int)), this, SLOT(updateTerminalIntOption(int)));
		connect(terminal_->fontAntialiasing_, SIGNAL(toggled(bool)), this, SLOT(updateTerminalBoolOption(bool)));
		connect(terminal_->subpixelAntialiasing_, SIGNAL(toggled(bool)), this, SLOT(updateTerminalBoolOption(bool)));
		connect(terminal_->lineSpacing_, SIGNAL(valueChanged(int)), this, SLOT(updateTerminalIntOption(int)));
		connect(terminal_->endlessLogging_, SIGNAL(toggled(bool)), this, SLOT(updateTerminalEndlessLogging(bool)));
		connect(terminal_->numberOfLines_, SIGNAL(valueChanged(int)), this, SIGNAL(terminalNumberOfLinesChanged(int)));
		connect(terminal_->endlessLogging_, SIGNAL(toggled(bool)), terminal_->numberOfLines_, SLOT(setDisabled(bool)));
		connect(terminal_->title_, SIGNAL(activated(const QString&)), this, SIGNAL(terminalTitleChanged(const QString&)));
		
		QStringList paletteNames;
		for (int i = 0, n = paletteManager_->numPalette(); i < n; ++i) {
			Ref<Palette> palette = paletteManager_->paletteByIndex(i);
			if (palette->numColors() >= QxVideoTerminal::NumColors) {
				paletteNames << paletteManager_->paletteByIndex(i)->displayName();
				paletteIndices_.append(i);
			}
		}
		
		QStringListModel* model = new QStringListModel(paletteNames, terminal_->palette_);
		terminal_->palette_->setModel(model);
		
		connect(terminal_->palette_, SIGNAL(activated(int)), this, SLOT(terminalPaletteActivated(int)));
	}
	
	{
		printing_ = new QxPrintingPreferences(tabs_);
		tabs_->insertTab(tabs_->count(), printing_, tr("Printing"));
		
		printing_->fontSize_->setRange(8, 32);
		printing_->lineSpacing_->setRange(0, 32);
	}
	
	/*
	{
		// performance HACK to reduce application launch time
		editor_->font_->setDisabled(true);
		terminal_->font_->setDisabled(true);
		printing_->font_->setDisabled(true);
		#ifdef Q_WS_MAC
		// visual HACK
		editor_->font_->setFixedWidth(editor_->font_->sizeHint().width());
		#endif
		#if 0
		editor_->font_->setMinimumContentsLength(20);
		editor_->font_->setSizeAdjustPolicy(QComboBox::AdjustToMinimumContentsLength);
		terminal_->font_->setMinimumContentsLength(20);
		terminal_->font_->setSizeAdjustPolicy(QComboBox::AdjustToMinimumContentsLength);
		printing_->font_->setMinimumContentsLength(20);
		printing_->font_->setSizeAdjustPolicy(QComboBox::AdjustToMinimumContentsLength);
		#endif
		QTimer::singleShot(0, this, SLOT(startFontFilter()));
	}
	*/
	
	{
		themesView_ = new QListView(tabs_);
		themesView_->setViewMode(QListView::IconMode);
		themesView_->setMovement(QListView::Static);
		themesView_->setResizeMode(QListView::Adjust);
		themesView_->setFlow(QListView::LeftToRight);
		// themesView_->setSpacing(10);
		
		tabs_->insertTab(tabs_->count(), themesView_, tr("Theme"));
		
		themesView_->setModel(new QxThemesModel(charcoalDirectory_, themesView_));
		
		connect(
			themesView_->selectionModel(), SIGNAL(currentRowChanged(const QModelIndex&, const QModelIndex&)),
			this, SLOT(themeActivate(const QModelIndex&, const QModelIndex&))
		);
	}
	
	{
		commands_ = new QxCommandsPreferences(tabs_);
		tabs_->insertTab(tabs_->count(), commands_, tr("Commands"));
		
		connect(commands_->add_, SIGNAL(clicked()), this, SLOT(addCommand()));
		connect(commands_->edit_, SIGNAL(clicked()), this, SLOT(editCommand()));
		connect(commands_->del_, SIGNAL(clicked()), this, SLOT(delCommand()));
		connect(commands_->import_, SIGNAL(clicked()), this, SLOT(importConfig()));
		connect(commands_->export_, SIGNAL(clicked()), this, SLOT(exportConfig()));
		
		commandsList_ = new QxCommandsList;
		commandsModel_ = new QxCommandsModel(commandsList_);
		commands_->view_->setModel(commandsModel_);
		commands_->view_->setHeaderHidden(false);
	}
	
	{
		codetips_ = new QxCodetipsPreferences(this, tabs_);
		tabs_->insertTab(tabs_->count(), codetips_, tr("Code Tips"));
	}
	
	{
		misc_ = new QxMiscPreferences(tabs_);
		tabs_->insertTab(tabs_->count(), misc_, tr("Misc"));
		misc_->scrollingSpeed_->setRange(1, 6);
		misc_->scrollingSpeed_->setValue(3);
		
		misc_->kinematicScrolling_->setChecked(true);
		misc_->scrollingSpeed_->setEnabled(false);
		connect(misc_->kinematicScrolling_, SIGNAL(toggled(bool)), misc_->scrollingSpeed_, SLOT(setDisabled(bool)));
		
		connect(misc_->kinematicScrolling_, SIGNAL(toggled(bool)), this, SLOT(updateEditorBoolOption(bool)));
		connect(misc_->kinematicScrolling_, SIGNAL(toggled(bool)), this, SLOT(updateTerminalBoolOption(bool)));
		connect(misc_->scrollingSpeed_, SIGNAL(valueChanged(int)), this, SLOT(updateEditorIntOption(int)));
		connect(misc_->scrollingSpeed_, SIGNAL(valueChanged(int)), this, SLOT(updateTerminalIntOption(int)));
		connect(misc_->scrollingSpeed_, SIGNAL(valueChanged(int)), this, SLOT(setWheelScrollLines(int)));
	}
	
	/*{
		config_ = new QxImportExportPreferences(tabs_);
		tabs_->insertTab(5, config_, tr("Import/Export"));
		
		config_->commands_->setChecked(true);
		connect(config_->import_, SIGNAL(pressed()), this, SLOT(importConfig()));
		connect(config_->export_, SIGNAL(pressed()), this, SLOT(exportConfig()));
	}*/
	
	QFontComboBox::FontFilters filters = QFontComboBox::MonospacedFonts|QFontComboBox::ScalableFonts;
	editor_->font_->setFontFilters(filters);
	terminal_->font_->setFontFilters(filters);
	printing_->font_->setFontFilters(filters);
	
	#ifndef QT_MAC_USE_COCOA
	resize(524, 390); // visual HACK
	#else
	resize(599, 421); // visual HACK
	#endif
}
Exemplo n.º 23
0
void cMenu::addCroppedText( uint32_t x, uint32_t y, uint32_t width, uint32_t height, unistring text, uint32_t hue )
{
	addCommand( "{croppedtext %d %d %d %d %d %d}", x, y, width, height, hue, addString(text) );
}
Exemplo n.º 24
0
HSceneHandlerItem::HSceneHandlerItem()
{
	// TODO: is it appropriate to add commands in the constructor or should they be registered somewhere else?
	addCommand(new CSceneHandlerItemExit());
}
Exemplo n.º 25
0
void cMenu::addResizeGump( uint32_t x, uint32_t y, uint32_t gump, uint32_t width, uint32_t height )
{
	addCommand( "{resizepic %d %d %d %d %d}", x, y, gump, width, height );
}
Exemplo n.º 26
0
    virtual void HandleMessage(const pp::Var& var_message) {
        // Receive a message from javascript.
        if (var_message.is_string()) {
            SkString msg(var_message.AsString().c_str());
            if (msg.startsWith("init")) {
            } else if (msg.startsWith("LoadSKP")) {
                size_t startIndex = strlen("LoadSKP");
                size_t dataSize = msg.size()/sizeof(char) - startIndex;
                SkBase64 decodedData;
                decodedData.decode(msg.c_str() + startIndex, dataSize);
                size_t decodedSize = 3 * (dataSize / 4);
                SkDebugf("Got size: %d\n", decodedSize);
                if (!decodedData.getData()) {
                    SkDebugf("Failed to decode SKP\n");
                    return;
                }
                SkMemoryStream pictureStream(decodedData.getData(), decodedSize);
                SkPicture* picture = SkPicture::CreateFromStream(&pictureStream);
                if (NULL == picture) {
                    SkDebugf("Failed to create SKP.\n");
                    return;
                }
                fDebugger.loadPicture(picture);
                picture->unref();

                // Set up the command list.
                SkTArray<SkString>* commands = fDebugger.getDrawCommandsAsStrings();
                PostMessage("ClearCommands");
                for (int i = 0; i < commands->count(); ++i) {
                    SkString addCommand("AddCommand:");
                    addCommand.append((*commands)[i]);
                    PostMessage(addCommand.c_str());
                }
                PostMessage("UpdateCommands");

                // Set the overview text.
                SkString overviewText;
                fDebugger.getOverviewText(NULL, 0.0, &overviewText, 1);
                overviewText.prepend("SetOverview:");
                PostMessage(overviewText.c_str());

                // Draw the SKP.
                if (!fFlushLoopRunning) {
                    Paint();
                }
            } else if (msg.startsWith("CommandSelected:")) {
                size_t startIndex = strlen("CommandSelected:");
                int index = atoi(msg.c_str() + startIndex);
                fDebugger.setIndex(index);
                if (!fFlushLoopRunning) {
                    Paint();
                }
            } else if (msg.startsWith("Rewind")) {
                fCanvas->clear(SK_ColorWHITE);
                fDebugger.setIndex(0);
                if (!fFlushLoopRunning) {
                    Paint();
                }
            } else if (msg.startsWith("StepBack")) {
                fCanvas->clear(SK_ColorWHITE);
                int currentIndex = fDebugger.index();
                if (currentIndex > 1) {
                    fDebugger.setIndex(currentIndex - 1);
                    if (!fFlushLoopRunning) {
                        Paint();
                    }
                }
            } else if (msg.startsWith("Pause")) {
                // TODO(borenet)
            } else if (msg.startsWith("StepForward")) {
                int currentIndex = fDebugger.index();
                if (currentIndex < fDebugger.getSize() -1) {
                    fDebugger.setIndex(currentIndex + 1);
                    if (!fFlushLoopRunning) {
                        Paint();
                    }
                }
            } else if (msg.startsWith("Play")) {
                fDebugger.setIndex(fDebugger.getSize() - 1);
                if (!fFlushLoopRunning) {
                    Paint();
                }
            }
        }
    }
Exemplo n.º 27
0
void cMenu::addInputField( uint32_t x, uint32_t y, uint32_t width, uint32_t height, uint16_t textId, unistring data, uint32_t hue )
{
	rc_edit.insert( make_pair( textId, rc_serialCurrent ) );
	addCommand( "{textentry %d %d %d %d %d %d %d}", x, y, width, height, hue, rc_serialCurrent++, addString(data) );
}
Exemplo n.º 28
0
void luConsoleEdit::OnKeyDown(wxKeyEvent& event)
{
	int ch = event.GetKeyCode();
	wxString str;
	
	if (ch == WXK_UP) 
	{
		pasteCommand(-1);
		return;
	} 
	else if (ch == WXK_DOWN) 
	{
		pasteCommand(+1);
		return;
	} 
	else if (ch == WXK_ESCAPE) 
	{
		pasteCommand(0);
		replaceCommand("");
		return;
	} 
	else if (ch == WXK_LEFT || ch == WXK_BACK) 
	{
		long x = 0, y = 0;
		if (PositionToXY(GetInsertionPoint(), &x, &y))
		{
			if (x <= (int)m_prompt.Length()) 
				return;
		}		
	} 
	else if (ch == WXK_HOME) 
	{
		long x = 0, y = 0;
		if (PositionToXY(GetInsertionPoint(), &x, &y))
		{
			x = m_prompt.Length();
			long pos = XYToPosition(x, y);
			SetSelection(pos, pos);
		}

		return;
	} 
	
	
	if (ch == WXK_RETURN) 
	{
		str = GetLineText(GetNumberOfLines() - 1);
		str.Replace(m_prompt, "");
	}
	else
	{
		event.Skip();
	}

	if (ch == WXK_RETURN) 
	{
		writeLine("\n");

		str.Trim().Trim(false);

		if (!str.IsEmpty()) 
		{
			runCmd(str, false, false);
			addCommand(str);
		} 
				
		writeLine(m_prompt);
		pasteCommand(0);
	}
}
Exemplo n.º 29
0
void cMenu::addRadioButton( uint32_t x, uint32_t y, uint32_t off, uint32_t on, uint32_t checked, int32_t result  )
{
	rc_radio.insert( make_pair( result, rc_serialCurrent ) );
	addCommand( "{radio %d %d %d %d %d %d}", x, y, off, on, checked, rc_serialCurrent++ );
}
Exemplo n.º 30
0
BattleChoiceWindow::BattleChoiceWindow() : CommandWindow(0, 0, GameWindow::main->width(), true, true) {
	addCommand(_t("Fight"));
	addCommand(_t("Escape"));
	
	m_columnMax = 2;
}