Exemplo n.º 1
0
void buildGui() {
	// status bar
	new StatusBar(0,0,CON_WIDTH,1);

	VBox *vbox=new VBox(0,2,1);
	// stats
	ToolBar *stats = new ToolBar(0,0,21,"Stats","Statistics about the current dungeon");
	stats->addWidget(new Label(0,0,wallRatioTxt,"Ratio of wall cells / total number of cells"));
	stats->addWidget(new Label(0,0,seedTxt,"Current random seed used to build the map"));
	vbox->addWidget(stats);
}
Exemplo n.º 2
0
Arquivo: App.cpp Projeto: 91yuan/ilixi
//-------------------------------------------------------------------------------------------------
// Main application
//-------------------------------------------------------------------------------------------------
App::App(int argc, char* argv[])
    : Application(&argc, &argv, OptDaleAuto),
      _sipComponent(NULL),
      _pid(0)
{
    setLayout(new HBoxLayout());
    setMargins(5, 5, 5, 5);

    //-------------------------------------------------------------------------------------------------
    // Create toolbar
    //-------------------------------------------------------------------------------------------------
    ToolBar* bar = new ToolBar();
    setToolbar(bar);

    _baresip = new ToolButton("Offline");
    _baresip->setIcon(StyleHint::Network);
    _baresip->setInputMethod(NoInput);
    _baresip->setDrawFrame(false);
    bar->addWidget(_baresip);

    bar->addWidget(new Spacer(Horizontal));

    _contactsButton = new ToolBarButton("Contacts");
    _contactsButton->setIcon(StyleHint::Contacts2);
    _contactsButton->sigClicked.connect(sigc::bind<int>(sigc::mem_fun(this, &App::showScreen), 0));
    bar->addWidget(_contactsButton);

    _historyButton = new ToolBarButton("Call Log");
    _historyButton->setIcon(StyleHint::Contacts1);
    _historyButton->sigClicked.connect(sigc::bind<int>(sigc::mem_fun(this, &App::showScreen), 1));
    bar->addWidget(_historyButton);

    _settingsButton = new ToolBarButton("Settings");
    _settingsButton->setIcon(StyleHint::Settings);
    _settingsButton->sigClicked.connect(sigc::bind<int>(sigc::mem_fun(this, &App::showScreen), 2));
    bar->addWidget(_settingsButton);

    _holdButton = new ToolBarButton("Hold");
    _holdButton->setVisible(false);
    _holdButton->setIcon(StyleHint::Pause);
    _holdButton->sigClicked.connect(sigc::mem_fun(this, &App::holdCall));
    bar->addWidget(_holdButton);

    _muteButton = new ToolBarButton("Mute");
    _muteButton->setVisible(false);
    _muteButton->setIcon(StyleHint::VolumeMuted);
    _muteButton->sigClicked.connect(sigc::mem_fun(this, &App::muteCall));
    bar->addWidget(_muteButton);

    _hangupButton = new ToolBarButton("Hang Up");
    _hangupButton->setVisible(false);
    _hangupButton->setIcon(StyleHint::Hangup);
    _hangupButton->sigClicked.connect(sigc::mem_fun(this, &App::hangupCall));
    bar->addWidget(_hangupButton);

    //-------------------------------------------------------------------------------------------------
    // Create views
    //-------------------------------------------------------------------------------------------------
    _manager = new ContactManager();

    _contacts = new Contacts(_manager);
    _contacts->sigCall.connect(sigc::mem_fun(this, &App::callContact));
    addWidget(_contacts);

    _history = new History();
    _history->sigCall.connect(sigc::mem_fun(this, &App::callContact));
    _history->setVisible(false);
    addWidget(_history);

    _settings = new Settings();
    _settings->setVisible(false);
    addWidget(_settings);

    _call = new Call();
    _call->setVisible(false);
    _call->sigHangup.connect(sigc::mem_fun(this, &App::hangupCall));
    addWidget(_call);

    _rightPanel = new VBoxLayout();
    addWidget(_rightPanel);

    _dialer = new Dialer();
    _rightPanel->addWidget(_dialer);

    _status = new Status();
    _rightPanel->addWidget(_status);

    //-------------------------------------------------------------------------------------------------
    // Incoming call dialog
    //-------------------------------------------------------------------------------------------------
    _incomingCall = new Dialog("Incoming Call", Dialog::YesNoButtonOption);
    _incomingCall->setLayout(new VBoxLayout());
    _caller = new Label("");
    Size s = _caller->preferredSize();
    _caller->setMinimumSize(PlatformManager::instance().getLayerSize().width() - 200, s.height());
    _incomingCall->addWidget(_caller);
    _incomingCall->addWidget(new Label("Do you wish to accept?"));
    _incomingCall->sigAccepted.connect(sigc::mem_fun(this, &App::acceptCall));
    _incomingCall->sigRejected.connect(sigc::mem_fun(this, &App::hangupCall));

    sigVisible.connect(sigc::mem_fun(this, &App::runBaresip));
}
Exemplo n.º 3
0
WidgetsDemo::WidgetsDemo(int argc, char* argv[])
        : Application(&argc, &argv, (AppOptions) (OptDaleAuto | OptSound))
{
    setMargins(5, 5, 5, 5);
    setLayout(new VBoxLayout());

    // ToolBar
    ToolBar* bar = new ToolBar();
    bar->addWidget(new Label("ilixi_widgets"));
    bar->addWidget(new Spacer(Horizontal));
    ToolBarButton* barButton = new ToolBarButton("Quit");
    barButton->setIcon(StyleHint::Cross);
    barButton->sigClicked.connect(sigc::ptr_fun(WidgetsDemo::quit));
    bar->addWidget(barButton);
    setToolbar(bar);

    // TabPanel
    TabPanel* tab = new TabPanel();
//    tab->surface()->setSurfaceFlag(Surface::SubSurface);
//    tab->surface()->unsetSurfaceFlag(Surface::SharedSurface);
    addWidget(tab);

    // Buttons Tab
    VBoxLayout* vBox = new VBoxLayout();
    tab->addTab(vBox, "Tab 1");

    // Label
    vBox->addWidget(createLabelGroup());
    vBox->addWidget(new LineSeperator());

    // CheckBox and RadioButton
    HBoxLayout* box1 = new HBoxLayout();
    box1->addWidget(createCheckGroup());
    box1->addWidget(createRadioGroup());
    vBox->addWidget(box1);
    vBox->addWidget(new LineSeperator());

    // PushButton
    vBox->addWidget(createPBGroup());
    vBox->addWidget(new LineSeperator());

    // ToolButton
    vBox->addWidget(createTBGroup());
    vBox->addWidget(new LineSeperator());

    // ButtonGroup
    DirectionalButton* db1 = new DirectionalButton("Left");
    DirectionalButton* db2 = new DirectionalButton("1");
    DirectionalButton* db3 = new DirectionalButton("2");
    DirectionalButton* db4 = new DirectionalButton("3");
    DirectionalButton* db5 = new DirectionalButton("Right");

    ButtonGroup* bg = new ButtonGroup(Horizontal);
    bg->addButton(db1);
    bg->addButton(db2);
    bg->addButton(db3);
    bg->addButton(db4);
    bg->addButton(db5);
    vBox->addWidget(bg);

    vBox->addWidget(new Spacer(Vertical));

    // Disabled
    VBoxLayout* vBox4 = new VBoxLayout();
    tab->addTab(vBox4, "Tab 2");
    tab->setTabEnabled(1, false);

    // LineInput Tab
    VBoxLayout* vBox2 = new VBoxLayout();
    tab->addTab(vBox2, "Tab 3");

    LineInput *li1 = new LineInput("123...");
    li1->sigTextEntered.connect(sigc::mem_fun(this, &WidgetsDemo::print));
    vBox2->addWidget(li1);
    vBox2->addWidget(new Spacer(Vertical));

    LineInput *li2 = new LineInput("Line input has some text...");
    vBox2->addWidget(li2);
    vBox2->addWidget(new Spacer(Vertical));

    LineInput *li3 = new LineInput("Line input has some text...");
    vBox2->addWidget(li3);
    vBox2->addWidget(new Spacer(Vertical));

    LineInput *li4 = new LineInput("Line input has some text...");
    vBox2->addWidget(li4);
    li4->setDisabled();
    vBox2->addWidget(new Spacer(Vertical));

    LineInput *li5 = new LineInput("Line input has some text...");
    vBox2->addWidget(li5);

    VBoxLayout* vBox3 = new VBoxLayout();
    tab->addTab(vBox3, "Tab 4");

    ProgressBar* bar1 = new ProgressBar();
    bar1->setValue(5);
    vBox3->addWidget(bar1);

    ProgressBar* bar1d = new ProgressBar();
    bar1d->setValue(5);
    bar1d->setDisabled();
    vBox3->addWidget(bar1d);

    Slider* slider1 = new Slider();
    slider1->sigValueChanged.connect(sigc::mem_fun(bar1, &ProgressBar::setValue));
    vBox3->addWidget(slider1);

    Slider* slider11 = new Slider();
    slider11->setValue(48);
    slider11->setDisabled();
    vBox3->addWidget(slider11);

    Slider* slider2 = new Slider();
    slider2->setInverted(true);
    slider2->sigValueChanged.connect(sigc::mem_fun(bar1, &ProgressBar::setValue));
    vBox3->addWidget(slider2);

    ScrollBar* sb1 = new ScrollBar(Horizontal);
    sb1->setRange(0, 10);
    vBox3->addWidget(sb1);

    ScrollBar* sb12 = new ScrollBar(Horizontal);
    sb12->setDisabled();
    sb12->setRange(0, 10);
    sb12->setValue(5);
    vBox3->addWidget(sb12);

    // Verticals
    HBoxLayout* vSliderLayout = new HBoxLayout();
    vBox3->addWidget(vSliderLayout);

    ProgressBar* bar2 = new ProgressBar();
    bar2->setValue(5);
    bar2->setOrientation(Vertical);
    vSliderLayout->addWidget(bar2);

    Slider* slider3 = new Slider();
    slider3->setOrientation(Vertical);
    slider3->sigValueChanged.connect(sigc::mem_fun(bar2, &ProgressBar::setValue));
    vSliderLayout->addWidget(slider3);

    Slider* slider4 = new Slider();
    slider4->setOrientation(Vertical);
    slider4->setInverted(true);
    slider4->sigValueChanged.connect(sigc::mem_fun(bar2, &ProgressBar::setValue));
    vSliderLayout->addWidget(slider4);

    ScrollBar* sb2 = new ScrollBar(Vertical);
    sb2->setRange(0, 10);
    vSliderLayout->addWidget(sb2);

    ComboBox::StringList list;

    char str[5];
    for (int i = 2005; i > 1900; --i)
    {
        sprintf(str, "%d", i);
        list.push_back(str);
    }

    ComboBox* co1 = new ComboBox("Select your date of birth:");
    co1->addItems(list);
    vBox3->addWidget(co1);

    SpinBox* spin1 = new SpinBox(5);
    vBox3->addWidget(spin1);


}
Exemplo n.º 4
0
void buildGui() {
	// status bar
	new StatusBar(0,0,HM_WIDTH,1);

	VBox *vbox=new VBox(0,2,1);
	// stats
	ToolBar *stats = new ToolBar(0,0,21,"Stats","Statistics about the current map");
	stats->addWidget(new Label(0,0,landMassTxt,"Ratio of land surface / total surface"));
	stats->addWidget(new Label(0,0,minZTxt,"Minimum z value in the map"));
	stats->addWidget(new Label(0,0,maxZTxt,"Maximum z value in the map"));
	stats->addWidget(new Label(0,0,seedTxt,"Current random seed used to build the map"));
	vbox->addWidget(stats);

	// tools
	ToolBar *tools=new ToolBar(0,0,15,"Tools","Tools to modify the heightmap");
	tools->addWidget(new Button("cancel","Delete the selected operation",cancelCbk,NULL));
	tools->addWidget(new Button("clear","Remove all operations and reset all heightmap values to 0.0",clearCbk,NULL));
	tools->addWidget(new Button("reseed","Replay all operations with a new random seed",reseedCbk,NULL));

	// operations
	tools->addSeparator("Operations","Apply a new operation to the map");
	addOperationButton(tools,Operation::NORM,normalizeCbk);
	addOperationButton(tools,Operation::ADDFBM,addFbmCbk);
	addOperationButton(tools,Operation::SCALEFBM,scaleFbmCbk);
	addOperationButton(tools,Operation::ADDHILL,addHillCbk);
	addOperationButton(tools,Operation::RAIN,rainErosionCbk);
	addOperationButton(tools,Operation::SMOOTH,smoothCbk);
	addOperationButton(tools,Operation::VORONOI,voronoiCbk);
	addOperationButton(tools,Operation::NOISELERP,noiseLerpCbk);
	addOperationButton(tools,Operation::ADDLEVEL,raiseLowerCbk);

	// display
	tools->addSeparator("Display","Change the type of display");
	RadioButton::setDefaultGroup(1);
	RadioButton *colormap=new RadioButton("colormap","Enable colormap mode",colorMapCbk,NULL);
	tools->addWidget(colormap);
	colormap->select();
	tools->addWidget(new RadioButton("slope","Enable slope mode",slopeCbk,NULL));
	tools->addWidget(new RadioButton("greyscale","Enable greyscale mode",greyscaleCbk,NULL));
	tools->addWidget(new RadioButton("normal","Enable normal map mode",normalCbk,NULL));
	tools->addWidget(new Button("change colormap","Modify the colormap used by hmtool", changeColorMapCbk,NULL));

	// change colormap gui
	colorMapGui=new ToolBar(0,0,"Colormap","Select the color and position of the keys in the color map");
	colorMapGui->setVisible(false);

	// in/out
	tools->addSeparator("In/Out","Import/Export stuff");
	tools->addWidget(new Button("export C","Generate the C code for this heightmap in ./hm.c",exportCCbk,NULL));
	tools->addWidget(new Button("export CPP","Generate the CPP code for this heightmap in ./hm.cpp",exportCppCbk,NULL));
	tools->addWidget(new Button("export PY","Generate the python code for this heightmap in ./hm.py",exportPyCbk,NULL));
	tools->addWidget(new Button("export bmp","Save this heightmap as a bitmap in ./hm.bmp",exportBmpCbk,NULL));

	vbox->addWidget(tools);

	// params box
	params = new ToolBar(0,0,"Params","Parameters of the current tool");
	vbox->addWidget(params);
	params->setVisible(false);

	// history
	history = new ToolBar(0,tools->y+1+tools->h,15,"History","History of operations");
	vbox->addWidget(history);
}
Exemplo n.º 5
0
void GraphicsTCOD::drawMainInterface()
{
    Widget::setConsole(output);
    
    HBox *hMenu=new HBox(12,-1,0);
    ToolBar *menuToolbar = new ToolBar(0,0,6,NULL,NULL);
    menuToolbar->addWidget(new Button("Menu",NULL,menuCbk,NULL));
    hMenu->addWidget(menuToolbar);
    
    
    ToolBar *playerToolbar = new ToolBar(0,0,6, NULL, NULL);
    playerToolbar->addWidget(new Button("Player", NULL, NULL, NULL));
    hMenu->addWidget(playerToolbar);
    
    ToolBar *socialToolbar = new ToolBar(0,0,6, NULL, NULL);
    socialToolbar->addWidget(new Button("Social", NULL, NULL, NULL));
    hMenu->addWidget(socialToolbar);
    
    
    ToolBar *worldToolbar = new ToolBar(0,0,6, NULL, NULL);
    worldToolbar->addWidget(new Button("World", NULL, NULL, NULL));
    hMenu->addWidget(worldToolbar);
    
    
    ToolBar *toolsToolbar = new ToolBar(0,0,6, NULL, NULL);
    toolsToolbar->addWidget(new Button("Tools", NULL, NULL, NULL));
    hMenu->addWidget(toolsToolbar);
    
    
    ToolBar *helpToolbar = new ToolBar(0,0,6, NULL, NULL);
    helpToolbar->addWidget(new Button("Help", NULL, NULL, NULL));
    hMenu->addWidget(helpToolbar);
    
    
    hMenu->setBackgroundColor(TCODColor(0,0,0), TCODColor(128,128,128));
    
    
    
    
    chatBox = new ScrollBox(0, 0, textOutputConsole->getWidth(), textOutputConsole->getHeight(), 512, textOutputConsole, cMap, this);
    serverBox = new ScrollBox(0, 0, serverConsole->getWidth(), serverConsole->getHeight()-2, 512, serverConsole, cMap, this);
    //serverBox->setConsole(serverConsole);
    chatBox->setRealPosition(0, 32);
    chatBox->takeCommands(true);
    commandConsole = chatBox;
    
    serverBox->setRealPosition(MAIN_WIDTH/2, 32);
    serverBox->takeCommands(true);
    
    
    serverBox->insertText("Welcome to The ASCII Project");
    serverBox->insertText(" Version 0.0.0o ");
    serverBox->insertText(" ");
    serverBox->insertText("Tip: all server input begins with ");
    serverBox->insertText("The / character.");
    
    serverBox->insertText(" ");
    serverBox->insertText(" ");
    serverBox->insertText(" ");
    
    serverBox->insertText("Please /connect to continue...");
    
    sConsole = chatBox;
    
    inputText = new TCODText(1, serverConsole->getHeight()-2, serverConsole->getWidth()-2, 1, serverConsole->getWidth()-2);
    inputText->setProperties(32, 1000, "$>", 1);
    inputText->setColors(TCODColor(0,255,0), TCODColor(0,0,0), 1.0f);
    inputText->render(serverConsole);
    
    
    //offscreenConsole->print(0,0, "Welcome To The ASCII Project");
    serverConsole->hline(0,serverConsole->getHeight()-1, serverConsole->getWidth());
    serverConsole->hline(0,serverConsole->getHeight()-3, serverConsole->getWidth());
    serverConsole->vline(0,0, serverConsole->getHeight());
    serverConsole->vline(serverConsole->getWidth()-1,0, serverConsole->getHeight());
    
    bool textInput = false;
    bool popupOpen = false;
    
    
    
    //bool placeActionMode = false;
    unpacking = true;
    connected = false;
    loggedIn = false;
    commandMode = false;
    APIinQueue = false;
    chatMessageInQueue = false;
    
    actionMode = "placeFloor";
    chatText = "";
    
    boost::asio::io_service pri_io_service;
    tcp::resolver pri_resolver(pri_io_service);
    
    if(DEBUG_MODE)
    {
        tcp::resolver::query pri_query("localhost", "5250");
        
        tcp::resolver::iterator iterator = pri_resolver.resolve(pri_query);
        
        cnet = new ClientSession(pri_io_service, iterator, cMap, this);
        
        
    }
    else
    {
        tcp::resolver::query pri_query("pub.theasciiproject.com", "5250");
        
        tcp::resolver::iterator iterator = pri_resolver.resolve(pri_query);
        
        cnet = new ClientSession(pri_io_service, iterator, cMap, this);
        
        
        
    }
    
    boost::thread netThread(&GraphicsTCOD::requestMap, this);
    
    
    //TCODConsole::disableKeyboardRepeat();
    
    
    while( !TCODConsole::isWindowClosed() )
    {
        TCOD_key_t key;
        TCOD_mouse_t mouse;
        
        TCODSystem::checkForEvent(TCOD_EVENT_KEY_PRESS|TCOD_EVENT_MOUSE,&key,&mouse);
        Widget::updateWidgets(key,mouse);

        if(!popupOpen)
        {
            if(textInput)
                inputText->update(key);
            
            chatBox->update(mouse);
            serverBox->update(mouse);
            
            
            
        }
        
        
        
        
        
        
        
        
        if(drawMenuCheck)
        {
            menuPopup=new VBox(35,10,0);
            ToolBar *menuPopupOptions = new ToolBar(0,0,6,NULL,NULL);
            menuPopupOptions->addWidget(new Button("Return",NULL,closeMenuCbk,NULL));
            menuPopupOptions->addWidget(new Button("Quit",NULL,quitCbk,NULL));
            menuPopup->addWidget(menuPopupOptions);
            
            popupOpen = true;
            drawMenuCheck = false;
        }
        
        if(closeMenuCheck)
        {
            menuPopup->clear();
            delete menuPopup;
            output->clear();
            
            fixBottom();
            
            popupOpen = false;
            closeMenuCheck = false;
        }
        
        if(!textInput && loggedIn)
        {
            
            if(key.vk == TCODK_SPACE)
            {
                if(commandMode)
                    commandMode = false;
                else
                    commandMode = true;
            }
            if(key.vk == TCODK_UP)
            {
                apiCall = "/8";
                APIinQueue = true;
            }
            else if(key.vk == TCODK_DOWN)
            {
                
                apiCall = "/2";
                APIinQueue = true;
            }
            else if(key.vk == TCODK_RIGHT)
            {
                
                apiCall = "/6";
                APIinQueue = true;
            }
            else if(key.vk == TCODK_LEFT)
            {
                
                apiCall = "/4";
                APIinQueue = true;
            }
            
            else if(key.c == 'w' && !commandMode)
            {
                
                apiCall = "/8";
                APIinQueue = true;
                
                
            }
            else if(key.c == 'a' && !commandMode)
            {
                
                apiCall = "/4";
                APIinQueue = true;
                
                
            }
            else if(key.c == 's' && !commandMode)
            {
                
                apiCall = "/2";
                APIinQueue = true;
                
            }
            else if(key.c == 'd' && !commandMode)
            {
                
                apiCall = "/6";
                APIinQueue = true;
                
            }
            else if(key.c == '5' && commandMode)
            {
                
                apiCall = "/mapReset";
                APIinQueue = true;
                
            }
            
            
            else if(key.c == '<' && !commandMode)
            {
                
                apiCall = "/5";
                APIinQueue = true;
                
            }
            else if(key.c == '>' && !commandMode)
            {
                
                apiCall = "/15";
                APIinQueue = true;
            }
            
            else if(key.c == 'i' && !commandMode)
            {
                if(actionMode == "removeTile")
                    apiCall = "/18";
                else if(actionMode == "placeWall")
                    apiCall = "/28";
                else if(actionMode == "placeFloor")
                    apiCall = "/38";
                else if(actionMode == "digHole")
                    apiCall = "/48";
                
                APIinQueue = true;
                
            }
            else if(key.c == 'j' && !commandMode)
            {
                if(actionMode == "removeTile")
                    apiCall = "/14";
                else if(actionMode == "placeWall")
                    apiCall = "/24";
                else if(actionMode == "placeFloor")
                    apiCall = "/34";
                else if(actionMode == "digHole")
                    apiCall = "/44";
                
                
                APIinQueue = true;
                
                
            }
            else if(key.c == 'k' && !commandMode)
            {
                if(actionMode == "removeTile")
                    apiCall = "/12";
                else if(actionMode == "placeWall")
                    apiCall = "/22";
                else if(actionMode == "placeFloor")
                    apiCall = "/32";
                else if(actionMode == "digHole")
                    apiCall = "/42";
                
                APIinQueue = true;
                
            }
            else if(key.c == 'l' && !commandMode)
            {
                if(actionMode == "removeTile")
                    apiCall = "/16";
                else if(actionMode == "placeWall")
                    apiCall = "/26";
                else if(actionMode == "placeFloor")
                    apiCall = "/36";
                else if(actionMode == "digHole")
                    apiCall = "/46";
                
                APIinQueue = true;
                
            }
            else if(key.c == 'u' && !commandMode)
            {
                if(actionMode == "digHole")
                {
                    apiCall = "/25";
                    
                    APIinQueue = true;
                }
                
            }
            else if(key.c == 'o' && !commandMode)
            {
                if(actionMode == "digHole")
                {
                    apiCall = "/35";
                    
                    APIinQueue = true;
                }
                
            }
            
            
            else if((key.c == 'd' || key.c == 'r') && commandMode)
            {
                actionMode = "removeTile";
            }
            else if(key.c == 'w' && commandMode)
            {
                actionMode = "placeWall";
            }
            else if(key.c == 'D' && commandMode)
            {
                actionMode = "digHole";
            }
            else if(key.c == 'f' && commandMode)
            {
                actionMode = "placeFloor";
            }
            
        }
        
        
        
        
        
        
        if(key.vk == TCODK_ESCAPE)
        {
            if(!textInput && !popupOpen)
            {
                drawMenuCheck = true;
                
            }
            
            inputText->reset();
            textInput = false;
            
            if(popupOpen)
            {
                closeMenuCheck = true;
            }
        }
        
        if(key.vk == TCODK_ENTER && textInput == true)
        {
            
            
            std::string tmpText = inputText->getText();
            
            if(tmpText != "" && tmpText.at(0) != '/')
            {
                if(!connected)
                {
                    
                    chatText = tmpText;
                    serverBox->insertText(chatText);
                    chatText = "";
                }
                else
                {
                    //chatText.clear();
                    chatText = tmpText;
                    chatMessageInQueue = true;
                    
                }
                
            }
            if(tmpText != "" &&  tmpText.at(0) == '/')
            {
                if(tmpText == "/connect" && !connected)
                {
                    // Begin Networking
                    
                    if(cnet->Connect())
                    {

                        chatBox->insertText("Connected Successfully");
                        chatBox->insertText(" ");
                        cnet->getLoginScreen();
                        chatBox->insertText(" ");
                        chatBox->insertText(" ");
                        connected = true;

                    }
                    else
                    {
                        chatBox->insertText("Failed to Connect, please retry");
                        connected = false;
                        
                    }
                    
                }
                else if(tmpText == "/connect" && connected)
                {
                    chatBox->insertText("Already Connected");
                }
                else if(tmpText == "/quit"  && connected)
                {
                    serverCommandInQueue = true;
                    serverCall = "/quit";
                    
                }
                else if (tmpText == "/quit" && !connected)
                {
                    exit(0);
                }
                else
                {
                    if(!connected)
                    {
                        chatBox->insertText("Not Connected, please /connect first");
                        
                    }
                    else if(connected && !loggedIn)
                    {
                        cnet->sendCommand(tmpText);
                        cnet->getResponse();
                    }
                    
                    else if(connected && loggedIn)
                    {
                        serverCommandInQueue = true;
                        serverCall = tmpText;
                    }
                }
            }
            
            inputText->reset();
            delete inputText;
            
            inputText = new TCODText(1, serverConsole->getHeight()-2, serverConsole->getWidth()-2, 1, serverConsole->getWidth()-2);
            inputText->setProperties(32, 1000, "$>", 1);
            inputText->setColors(TCODColor(0,255,0), TCODColor(0,0,0), 1.0f);
            
            textInput = false;

        }
        else if(key.vk == TCODK_ENTER && textInput == false)
        {
            textInput = true;
        }

        mapOutput->clear();
        

        if(connected && loggedIn && !commandMode)
        {
            mapOutput->setDefaultForeground(TCODColor(255,255,255));
            mapOutput->printEx(mapOutput->getWidth()/2, mapOutput->getHeight()-1, TCOD_BKGND_NONE, TCOD_CENTER, "Action Mode", TCODColor(255,255,255));
        }
        else if(connected && loggedIn && commandMode)
        {
            mapOutput->setDefaultForeground(TCODColor(255,255,255));
            mapOutput->printEx(mapOutput->getWidth()/2, mapOutput->getHeight()-1, TCOD_BKGND_NONE, TCOD_CENTER, "Select Mode", TCODColor(255,255,255));
        }


        
        requestMap();
        
       // if(!unpacking)
       //     drawAll();


        drawAll();

        
        TCODConsole::blit(mapOutput, 0, 0, 0, 0, output, 0, 2);
        inputText->render(serverConsole);
        chatBox->render();
        serverBox->render();
        Widget::renderWidgets();
        fixBottom();
        
        

        TCODConsole::blit(serverConsole,0,0,0,0,output,MAIN_WIDTH/2,32, 1.0f, 1.0f);
        TCODConsole::blit(textOutputConsole,0,0,0,0,output,0,32, 1.0f, 1.0f);
        render();
        //mapOutput->clear();

        
        /* if((key.c == 'a' || key.c == 's' || key.c == 'w' || key.c == 'd') && connected && loggedIn && !textInput)
         {
         while(key.vk != TCODK_NONE)
         {
         TCODSystem::checkForEvent(TCOD_EVENT_KEY_PRESS|TCOD_EVENT_MOUSE,&key,&mouse);
         }
         } */
        
        
    }
    
    
    
}
Exemplo n.º 6
0
void GraphicsTCOD::drawMenu()
{
    Widget::setConsole(output);
    
    
    //new StatusBar(0,0,MAP_WINDOW_WIDTH,1);
    
    VBox *vbox=new VBox(MAIN_WIDTH/2 - 7,MAIN_HEIGHT/2 + 10,0);
    ToolBar *mainMenu = new ToolBar(MAIN_WIDTH/2 - 7,MAIN_HEIGHT/2 + 10,15,NULL,NULL);
    //stats->addWidget(new Label(MAP_WINDOW_WIDTH/2 - 7,MAP_WINDOW_HEIGHT/2 - 6,"Login","Login"));
    mainMenu->addWidget(new Button("Connect",NULL,loginCbk,NULL));
    //stats->addWidget(new Label(MAP_WINDOW_WIDTH/2 - 7,MAP_WINDOW_HEIGHT/2 - 5,"New Account","New Account"));
    //stats->addWidget(new Button("New Account",NULL,newAccountCbk,NULL));
	//stats->addWidget(new Label(MAP_WINDOW_WIDTH/2 - 7,MAP_WINDOW_HEIGHT/2 - 4,"Options","Options"));
    mainMenu->addWidget(new Button("Options",NULL,NULL,NULL));
    //stats->addWidget(new Label(MAP_WINDOW_WIDTH/2 - 7,MAP_WINDOW_HEIGHT/2 - 3,"Quit","Quit"));
    mainMenu->addWidget(new Button("Quit",NULL,quitCbk,NULL));
    vbox->addWidget(mainMenu);
    
    Widget::setBackgroundColor(TCODColor(0,0,0), TCODColor(128,128,128));
    Widget::setForegroundColor(TCODColor(255,255,255), TCODColor(255,255,255));
    
    Widget::renderWidgets();
    
    TCODMouse::showCursor(true);
    
    TCODImage *image = new TCODImage("data/images/MenuBackground.png");
    
    
    // bool quit = false;
    while(!TCODConsole::isWindowClosed())
    {
        TCOD_key_t key;
        TCOD_mouse_t mouse;
        
        TCODSystem::checkForEvent(TCOD_EVENT_KEY_PRESS|TCOD_EVENT_MOUSE,&key,&mouse);
        Widget::updateWidgets(key,mouse);
        
        Widget::renderWidgets();
        
        render();
        
        image->blitRect(output, 2, 0);
        
        output->setDefaultForeground(TCODColor(255, 255, 255));
        output->print(MAIN_WIDTH-26, MAIN_HEIGHT-3, (const char*)"The ASCII Project 0.0.0o", TCOD_LEFT);
        output->print(MAIN_WIDTH-29, MAIN_HEIGHT-2, (const char*)"TheASCIIProject.com (c)2012", TCOD_LEFT);
        output->rect(0, 0, 20, 1, true);
        
        
        if(drawLogin || key.vk == TCODK_ENTER)
        {
            break;
        }
        else if( key.vk == TCODK_ESCAPE)
        {
            exit(0);
        }
        
    }
    
    vbox->removeWidget(mainMenu);
    delete vbox;
    
    output->setDefaultBackground(TCODColor(0, 0, 0));
    output->clear();
    render();
    
    
}