MainMenuState::MainMenuState(Vector2 screenSize, ALLEGRO_KEYBOARD_STATE* keyState, ALLEGRO_KEYBOARD_STATE* prevKeyState, ALLEGRO_MOUSE_STATE* mouseState, ALLEGRO_MOUSE_STATE* prevMouseState, ALLEGRO_FONT* font) : GameState(screenSize, keyState, prevKeyState, mouseState, prevMouseState) { cout << "Main State initialized" << endl; this->font = font; background = al_load_bitmap("assets/img/selectGameScreen/Starfield.png"); leftDoor = GameObject("assets/img/selectGameScreen/Leftblastdoor.png", Vector2(1, 1), 30, Vector2()); rightDoor = GameObject("assets/img/selectGameScreen/Rightblastdoor.png", Vector2(1, 1), 30, Vector2(457, 0)); //457 = 559 (size of left door) - 102 (overlap between doors) mainButton = Button("assets/img/selectGameScreen/StartButton.png", Vector2(1, 1), 100, "assets/img/selectGameScreen/StartButton.png", Vector2(1, 1), 100, "assets/img/selectGameScreen/StartButtonHover.png", Vector2(2, 1), 100, Vector2(300, 200), true); cout << "Main button loaded" << endl; opening = false; /*********************************************************************************************** ****************************************** Planets ******************************************** ***********************************************************************************************/ Vector2 center = Vector2(getScreenSize().x / 2, getScreenSize().y / 2); planets.push_back(PlanetButton("Play", font, "assets/img/gameMenuCircles/Center.png", center, 0, 0, 0.001, 0.001)); planets.push_back(PlanetButton("Instructions", font, "assets/img/gameMenuCircles/Planet1.png", center, 175, M_PI / 2, 0.0003, 0.002)); planets.push_back(PlanetButton("Back", font, "assets/img/gameMenuCircles/Planet3.png", center, 350, M_PI, -0.0002, -0.0015)); planets.push_back(PlanetButton("Quit", font, "assets/img/gameMenuCircles/Planet2.png", center, 410, M_PI, -0.00015, 0.003)); }
MenuState::MenuState(sf::Font& mainFont, ScoreBoard* scoreBoard) { if (!menuBg.load(menuResPath, sf::Vector2u(pixelSizeX, pixelSizeY), level, xPixels, yPixels)) throw std::runtime_error("Failed to load the tilemap probably because file was not found."); sf::Vector2f playButtonLocation(screenResWidth / 2 - buttonSizeX / 2, screenResHeight / 2 - buttonSizeY / 2); sf::Vector2f exitButtonLocation(playButtonLocation); exitButtonLocation.y += buttonSizeY * 2; playButton = Button("PLAY", playButtonLocation, mainFont); exitButton = Button("EXIT", exitButtonLocation, mainFont); playButton.activate(); introText.setString("SNAKE!"); introText.setColor(sf::Color(84, 191, 88)); introText.setPosition(screenResWidth / 2 - buttonSizeX + pixelSizeX, screenResHeight / 2 - 3 * buttonSizeY); introText.setCharacterSize(210); introText.setFont(mainFont); highScore.setString(scoreBoard->getHighScore()); highScore.setCharacterSize(pixelSizeX * 3); highScore.setPosition(pixelSizeX * 2, screenResHeight / 2 + pixelSizeY * 3); highScore.setFont(mainFont); highScoreHeader.setString("Highscore"); highScoreHeader.setCharacterSize(pixelSizeX * 3); highScoreHeader.setPosition(0, screenResHeight / 2); highScoreHeader.setFont(mainFont); //buttonArr[0] = playButton; //buttonArr[1] = exitButton; //arrSize = 2; //activeIndex = 0; //snakeLogo; }
void main() { TRISA=0x01; TRISB=0x00; Start: PORTA=0x00; Data=0x00; PORTA=0x02; //Set Latch HIGH Delay_ms(2); PORTA=0x00; Delay_ms(1); if (Button(&PORTA, 0, 1, 1))temp1=0; else temp1=1; Data|=temp1; for(i=1;i<8;i++){//Read(); Delay_ms(1); PORTA=0x04; temp1=0; if (Button(&PORTA, 0, 1, 1))temp1=0; else temp1=BITS[i]; Data|=temp1; Delay_ms(1); PORTA=0x00; } PORTB=Data; goto Start; }
Menu::Menu() : visible(true) { onCredits = false; bg.LoadFromFile("img/menubg.png"); title.LoadFromFile("img/title.png"); float bx = 310, by = 430; bLvl1 = Button(bx, by); bLvl1.setText("Initiation"); bLvl1.setCallback(Menu::initLevel1); by += 25; bLvl2 = Button(bx, by); bLvl2.setText("La tourmente"); bLvl2.setCallback(Menu::initLevel2); by += 25; bLvl3 = Button(bx, by); bLvl3.setText("Challenge++"); bLvl3.setCallback(Menu::initLevel3); by += 25; bShowCredits = Button(580,715); bShowCredits.setCallback(Menu::actionShowCredits); bShowCredits.setText("Credits"); bHideCredits = Button(580,715); bHideCredits.setCallback(Menu::actionHideCredits); bHideCredits.setText("Retour"); }
LevelEditorMenu::LevelEditorMenu(ResourceManager* resourceManager) : button_test(sf::Vector2f(10.0f, 10.0f), resourceManager->getTexture("Graphics/Menu/test.png")), button_save(sf::Vector2f(202.0f, 10.0f), resourceManager->getTexture("Graphics/Menu/save.png")), button_tiles(sf::Vector2f(394.0f, 10.0f), resourceManager->getTexture("Graphics/Menu/tiles.png")), button_clear(sf::Vector2f(202.0f, 45.0f), resourceManager->getTexture("Graphics/Menu/clear.png")), button_toggleGrid(sf::Vector2f(10.0f, 45.0f), resourceManager->getTexture("Graphics/Menu/toggle_grid.png")), button_toggleCollisionLines(sf::Vector2f(394.0f, 45.0f), resourceManager->getTexture("Graphics/Menu/toggle_collision_lines.png")) { items.push_back(&button_save); items.push_back(&button_test); items.push_back(&button_tiles); items.push_back(&button_toggleGrid); items.push_back(&button_clear); items.push_back(&button_toggleCollisionLines); //! Buttons for button_tiles float blockPosX = 10.0f, blockPosY = 80.0f; for (int i = 0; i < BUTTONT_TILES_CHILDS_SIZE - 1; ++i) //! First 3 buttons are blocks { std::stringstream ss; ss << i + 1; button_tiles_childs[i] = Button(sf::Vector2f(blockPosX, blockPosY), resourceManager->getTexture("Graphics/Menu/block" + ss.str() + ".png")); blockPosX += 60.0f; } button_tiles_childs[3] = Button(sf::Vector2f(190.0f, 95.0f), resourceManager->getTexture("Graphics/Menu/collision_pointer.png"), nullptr, false); for (int i = 0; i < BUTTONT_TILES_CHILDS_SIZE; ++i) button_tiles.items.push_back(&button_tiles_childs[i]); }
MainMenu::MainMenu() { playButton = Button(325,400,150,50,sf::Color(97,56,11),"New"); loadButton = Button(325,280,150,50,sf::Color(97,56,11),"Load"); title = sf::Text(); title.setString("Splunk"); title.setCharacterSize(50); title.setFont(ResourceManager::PixelFont); }
NS_IMETHODIMP TaskbarPreviewButton::SetHasBorder(PRBool hasBorder) { if (hasBorder) Button().dwFlags &= ~THBF_NOBACKGROUND; else Button().dwFlags |= THBF_NOBACKGROUND; return Update(); }
NS_IMETHODIMP TaskbarPreviewButton::SetDisabled(PRBool disabled) { if (disabled) Button().dwFlags |= THBF_DISABLED; else Button().dwFlags &= ~THBF_DISABLED; return Update(); }
NS_IMETHODIMP TaskbarPreviewButton::SetVisible(PRBool visible) { if (visible) Button().dwFlags &= ~THBF_HIDDEN; else Button().dwFlags |= THBF_HIDDEN; return Update(); }
NS_IMETHODIMP TaskbarPreviewButton::SetDismissOnClick(PRBool dismiss) { if (dismiss) Button().dwFlags |= THBF_DISMISSONCLICK; else Button().dwFlags &= ~THBF_DISMISSONCLICK; return Update(); }
Options::Options(std::string menuName) { setName(menuName); menuButtons = std::vector<Button>(); menuButtons.push_back(Button(73, 79, 230, 255, 400, 100, 100, 100, "Option1", "Option 1",12)); menuButtons.push_back(Button(135, 230, 84, 255, 400, 100, 100, 210, "Option2", "Option2",12)); menuButtons.push_back(Button(230, 78, 68, 255, 400, 100, 100, 320, "Back", "Go Back",12)); };
void SongControl::showGui() { if (_gui) _gui->deleteMe(); _gui = safe_new(Frame(_gui_parent, 0, 0, 0, 0, 1)); safe_new(Button(_gui, 0, 0, "Play", playAction())); safe_new(Button(_gui, 0, 0, "Stop", stopAction())); safe_new(Button(_gui, 0, 0, "Plus", increaseTempoAction())); safe_new(Button(_gui, 0, 0, "Minus", decreaseTempoAction())); _gui->packHorizontally(5); }
void init(){ grabber.init(pa("-i")); bool c_arg = pa("-c"); gui << Draw().handle("draw").label("input image") << Image().handle("cropped").label("cropped") << ( VBox().maxSize(c_arg ? 0 : 12,99).minSize(c_arg ? 0 : 12,1) << Button("save as ..").handle("saveAs") << Button("overwrite input").handle("overwrite") << Combo("0,90,180,270").handle("rot").label("rotation") << CheckBox("rectangular",!pa("-r")).handle("rect") << Button("Batch crop...").handle("batch") << ( HBox().label("rectification size") << Spinner(1,4096,640).handle("s1") << Label(":") << Spinner(1,4096,480).handle("s2") ) << (HBox() << Fps().handle("fps") << CamCfg() ) ) << Show(); if(!c_arg){ gui["batch"].registerCallback(batch_crop); } const ImgBase *image = grabber.grab(); if(!c_arg){ mouse_1 = new Mouse1(image->getSize()); gui["draw"].install(mouse_1); } mouse_2 = new Mouse2(image->getSize()); gui["draw"].install(mouse_2); DrawHandle draw = gui["draw"]; draw->setImageInfoIndicatorEnabled(false); if(!c_arg){ gui["rect"].registerCallback(rectangular_changed); rectangular_changed(); if(*pa("-i",0) != "file" || FileList(*pa("-i",1)).size() != 1){ gui["overwrite"].disable(); }else{ gui["overwrite"].registerCallback(overwrite); } gui["saveAs"].registerCallback(save_as); } }
void generateMenu(std::vector<Button> &buttons, std::vector<Sine> &sines) { // draw buttons buttons.push_back(Button(100, 150, "250")); buttons.push_back(Button(100, 250, "1000")); buttons.push_back(Button(100, 350, "2000")); // load up sounds sines.push_back(Sine(250)); sines.push_back(Sine(1000)); sines.push_back(Sine(2000)); }
NS_IMETHODIMP TaskbarPreviewButton::SetImage(imgIContainer *img) { if (Button().hIcon) ::DestroyIcon(Button().hIcon); if (img) { nsresult rv; rv = nsWindowGfx::CreateIcon(img, PR_FALSE, 0, 0, &Button().hIcon); NS_ENSURE_SUCCESS(rv, rv); } else { Button().hIcon = NULL; } return Update(); }
IngameMenu::IngameMenu() : visible(false) { float bx = 310, by = 250; bQuit = Button(bx, by); bQuit.setText("Quitter"); bQuit.setCallback(IngameMenu::quitAction); by += 25; bCancel = Button(bx, by); bCancel.setText("Annuler"); bCancel.setCallback(IngameMenu::cancelAction); by += 25; }
NS_IMETHODIMP TaskbarPreviewButton::SetImage(imgIContainer *img) { if (Button().hIcon) ::DestroyIcon(Button().hIcon); if (img) { nsresult rv; rv = nsWindowGfx::CreateIcon(img, false, 0, 0, nsWindowGfx::GetIconMetrics(nsWindowGfx::kRegularIcon), &Button().hIcon); NS_ENSURE_SUCCESS(rv, rv); } else { Button().hIcon = nullptr; } return Update(); }
//need to add button for uploading void initWindowUploader(int width, int height){ windowUploader = SDL_CreateWindow("Image To Upload", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, width, height + (ButtonHeight + 26), 0); rendererUploader = SDL_CreateRenderer(windowUploader, -1, 0); string filepath = ExePath() + '\\' + "screenshot.bmp"; image = SDL_LoadBMP(filepath.c_str()); imageTexture = SDL_CreateTextureFromSurface(rendererUploader, image); //uploadButton = SDL_LoadBMP("uploadbutton.bmp"); //buttonTexture = SDL_CreateTextureFromSurface(rendererUploader, uploadButton); SDL_SetRenderDrawColor(rendererUploader, 255, 255, 255, 0); SDL_RenderClear(rendererUploader); SDL_Rect imageRect = { 0 , 0, width, height }; SDL_RenderCopy(rendererUploader, imageTexture, NULL, &imageRect); //SDL_Rect buttonRect = { width - (ButtonWidth + 13), height + 13, ButtonWidth, ButtonHeight }; //SDL_RenderCopy(rendererUploader, buttonTexture, NULL, &buttonRect); //add buttons uploadButton = Button(width - (ButtonWidth + 13), height + 13, ButtonWidth, ButtonHeight, "UploadButtonSprite.bmp"); uploadButton.show(rendererUploader); SDL_RenderPresent(rendererUploader); uploaderRunning = true; initKeyBindings(); }
NS_IMETHODIMP MouseEvent::GetButton(int16_t* aButton) { NS_ENSURE_ARG_POINTER(aButton); *aButton = Button(); return NS_OK; }
void init(){ gui << Plot().handle("plot") << Button("run").handle("run") << Show(); vq.init(pa("-n")); URand cs(-5,5); GRand gr(0,pa("-v")); int n=pa("-s"); for(int i=pa("-c");i>=0;--i){ V2 c(cs,cs); for(int j=0;j<n;++j){ D.push_back(c + V2(gr,gr)); } } PlotHandle plot = gui["plot"]; plot->setPropertyValue("tics.y-distance",2); plot->setPropertyValue("tics.x-distance",2); plot->label("data"); plot->scatter(&D[0][0],&D[0][1],D.size(),2,2); plot->linewidth(2); }
int main () { int ret; Rect windRect; long start,end,amount; /* Initialize all the needed managers. */ InitGraf(&qd.thePort); InitFonts(); InitWindows(); InitMenus(); TEInit(); InitDialogs(nil); InitCursor(); //ProfilerInit(collectDetailed, bestTimeBase, 1000, 50); //ProfilerSetStatus(true); windRect = qd.screenBits.bounds; InsetRect(&windRect, 50, 50); pWindow = NewCWindow(nil, &windRect, "\pMpeg", true, documentProc, (WindowPtr) -1, false, 0); start = TickCount(); main2(); end = TickCount(); amount = end - start; fprintf(stderr, "Time taken %d memoryAllocator %d \n", amount,counter); // ProfilerDump("\pProfile.out"); do { } while (!Button()); }
void StatusBar::Init() { backgrnd = NXUI["StatusBar.img"]["base"]["backgrnd"]; backgrnd2 = NXUI["StatusBar.img"]["base"]["backgrnd2"]; gauge_bar = NXUI["StatusBar.img"]["gauge"]["bar"]; gauge_grad = NXUI["StatusBar.img"]["gauge"]["graduation"]; // Load level numbers Node levels = NXUI["Basic.img"]["LevelNo"]; for (uint8_t i = 0; i < 10; ++i) { level_no[i] = levels[i]; } buttons.push_back(Button(NXUI["StatusBar.img"]["BtMenu"], 0, 0)); buttons.push_back(Button(NXUI["StatusBar.img"]["BtShop"], 0, 0)); buttons.push_back(Button(NXUI["StatusBar.img"]["BtShort"], 0, 0)); }
void NGLScene::addButton(ngl::Vec2 _pos, ngl::Vec2 _size, ngl::Vec4 _color, Button::Action _action) { GLuint textureID = 0; //GLuint textureID = loadTexture(_textureFile); //std::cout << "textureID: " << textureID << std::endl; m_buttons.push_back(Button(_pos, _size, _color, _action, textureID)); }
EditorHelpSearch::EditorHelpSearch(EditorNode *p_editor) { editor=p_editor; VBoxContainer *vbc = memnew( VBoxContainer ); add_child(vbc); set_child_rect(vbc); HBoxContainer *sb_hb = memnew( HBoxContainer); search_box = memnew( LineEdit ); sb_hb->add_child(search_box); search_box->set_h_size_flags(SIZE_EXPAND_FILL); Button *sb = memnew( Button("Search")); sb->connect("pressed",this,"_update_search"); sb_hb->add_child(sb); vbc->add_margin_child("Search:",sb_hb); search_box->connect("text_changed",this,"_text_changed"); search_box->connect("input_event",this,"_sbox_input"); search_options = memnew( Tree ); vbc->add_margin_child("Matches:",search_options,true); get_ok()->set_text("View"); get_ok()->set_disabled(true); register_text_enter(search_box); set_hide_on_ok(false); search_options->connect("item_activated",this,"_confirmed"); set_title("Search Classes"); // search_options->set_hide_root(true); }
void VarioSettingMenu(void) { uint8_t button_state, button_prev_state; uint16_t timeout = VARIO_SETTING_MENU_TIMEOUT; VarioSettingEnterSound(); while(ButtonState()) // wait for button to be released delay_ms(1); CheckBuzzerStart(); VarioSettingPlayDelay = VARIO_SETTING_PLAY_DELAY/3; VarioSettingPlayState = VARIO_STATE_IDDLE; button_prev_state = ButtonState(); do { CheckBuzzer(true); button_state = ButtonState(); if ((!button_state)&&(button_prev_state)) { timeout = VARIO_SETTING_MENU_TIMEOUT; VarioSettingButtonPushed(); } button_prev_state = button_state; VarioSettingPlay(); BuzzerTask(); } while( (Button() != BUTTON_LONG) && timeout-- ); VarioSettingExitSound(); // exit Vario settings }
bool MenuButtonStripPreview::AddButton(const std::string &norm_path, const std::string &hover_path, const sf::Vector2f &pos, bool selected, std::string dest, std::string prvw_img_path, sf::Vector2f &prvw_img_pos) { bool ret = true; Button temp_btn = Button(); if (temp_btn.Initialise(norm_path, hover_path, pos, selected, dest)) { ret = false; } vec_btn_.push_back(temp_btn); sf::Texture temp_txtre = sf::Texture(); if (!temp_txtre.loadFromFile(prvw_img_path)) { OutputDebugString(L"Error loading lobby preview texture"); ret = false; } preview_image_.setTexture(temp_txtre); preview_image_.setPosition(prvw_img_pos); return ret; }
wxMouseState wxGetMouseState() { wxMouseState ms; wxPoint pt = wxGetMousePosition(); ms.SetX(pt.x); ms.SetY(pt.y); #if TARGET_API_MAC_OSX UInt32 buttons = GetCurrentButtonState(); ms.SetLeftDown( (buttons & 0x01) != 0 ); ms.SetMiddleDown( (buttons & 0x04) != 0 ); ms.SetRightDown( (buttons & 0x02) != 0 ); #else ms.SetLeftDown( Button() ); ms.SetMiddleDown( 0 ); ms.SetRightDown( 0 ); #endif UInt32 modifiers = GetCurrentKeyModifiers(); ms.SetControlDown(modifiers & controlKey); ms.SetShiftDown(modifiers & shiftKey); ms.SetAltDown(modifiers & optionKey); ms.SetMetaDown(modifiers & cmdKey); return ms; }
MixerGui::MixerGui(SafePtr<IControl> parent, MainMixer* mixer) : Window(parent, 0, 0, 600, 300, "Main mixer"), _mixer(mixer) { SafePtr<IControl> hframe = safe_new(Frame(safePtr(), 0, 0, 600, 300, 0)); // Main volume controls SafePtr<IControl> frame = safe_new(Frame(hframe, 0, 0, 20, 300, 0)); SafePtr<Label> header = safe_new(Label(frame, 0, 20, "M")).cast<Label>(); SafePtr<Slider> slider = safe_new(Slider(frame, 0, 40, 280, 0.0, 1.5, &_mixer->getMasterVolume()->_vol, 50)).cast<Slider>(); header->setPreferedSize(0, 14, 1); slider->setPreferedSize(0, 0, 1); frame->packVertically(5); frame->setPreferedSize(0, 0, 1); for (int i = 0; i < _mixer->getChannels(); ++i) { char buffer[16]; sprintf(buffer, "Ch.%i", i+1); SafePtr<IControl> frame = safe_new(Frame(hframe, 0, 0, 20, 300, 0)); SafePtr<Button> button = safe_new(Button(frame, 0, 0, "SQ.", mixer->getSynthQueue(i)->showGuiAction())).cast<Button>(); SafePtr<Label> header = safe_new(Label(frame, 0, 20, buffer)).cast<Label>(); SafePtr<Slider> slider = safe_new(Slider(frame, 0, 40, 280, 0.0, 1.5, &_mixer->getVolume(i)->_vol, 50)).cast<Slider>(); button->setPreferedSize(0, 22, 1); header->setPreferedSize(0, 14, 1); slider->setPreferedSize(0, 0, 1); frame->packVertically(5); frame->setPreferedSize(0, 0, 1); } hframe->packHorizontally(5); }
EditorPluginSettings::EditorPluginSettings() { plugin_config_dialog = memnew(PluginConfigDialog); plugin_config_dialog->config(""); add_child(plugin_config_dialog); HBoxContainer *title_hb = memnew(HBoxContainer); title_hb->add_child(memnew(Label(TTR("Installed Plugins:")))); title_hb->add_spacer(); create_plugin = memnew(Button(TTR("Create"))); create_plugin->connect("pressed", this, "_create_clicked"); title_hb->add_child(create_plugin); update_list = memnew(Button(TTR("Update"))); update_list->connect("pressed", this, "update_plugins"); title_hb->add_child(update_list); add_child(title_hb); plugin_list = memnew(Tree); plugin_list->set_v_size_flags(SIZE_EXPAND_FILL); plugin_list->set_columns(5); plugin_list->set_column_titles_visible(true); plugin_list->set_column_title(0, TTR("Name:")); plugin_list->set_column_title(1, TTR("Version:")); plugin_list->set_column_title(2, TTR("Author:")); plugin_list->set_column_title(3, TTR("Status:")); plugin_list->set_column_title(4, TTR("Edit:")); plugin_list->set_column_expand(0, true); plugin_list->set_column_expand(1, false); plugin_list->set_column_expand(2, false); plugin_list->set_column_expand(3, false); plugin_list->set_column_expand(4, false); plugin_list->set_column_min_width(1, 100 * EDSCALE); plugin_list->set_column_min_width(2, 250 * EDSCALE); plugin_list->set_column_min_width(3, 80 * EDSCALE); plugin_list->set_column_min_width(4, 40 * EDSCALE); plugin_list->set_hide_root(true); plugin_list->connect("item_edited", this, "_plugin_activity_changed"); VBoxContainer *mc = memnew(VBoxContainer); mc->add_child(plugin_list); mc->set_v_size_flags(SIZE_EXPAND_FILL); mc->set_h_size_flags(SIZE_EXPAND_FILL); add_child(mc); updating = false; }
// ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ // ¥ CWaitMouseDownStatement::ExecuteSelf // ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ void CWaitMouseDownStatement::ExecuteSelf(CProgram &inState) { if (USE_RNE_FOR_SYNC_INPUT) { // if the mouse button is held when we enter, then we're done instantly if (Button()) return; // otherwise, block our task until we get an event, if it's a mouse click, unblock, if not, handle it and reblock // this drops our cpu usage from 100 to pretty much zero on mac os x EventRef e; // clear all pending mouse downs so we don't return immediately { EventTypeSpec eventsList[]={ { kEventClassMouse, kEventMouseDown } }; ::FlushEventsMatchingListFromQueue(GetCurrentEventQueue(),1,eventsList); } // wait for a standard event with an infinite time out, this includes esc and cmd-. etc inState.TBReceiveNextEvent(EventListWithCount(CApplication::kStdEventsListPlusAllMouse),kEventDurationForever,false,&e); // if it's a mouse click, flush it and exit, if it's not a mouse click, don't flush it, let it be handled then repeat if ((::GetEventClass(e)==kEventClassMouse) && (::GetEventKind(e)==kEventMouseDown) && inState.MouseEventIsOverGameWindow(e)) { // remove the event from the queue ::RemoveEventFromQueue(GetCurrentEventQueue(),e); // we now own e ::ReleaseEvent(e); } else { ECHO("Non mouse up event, passing out and looping..."); inState.SetPC(this); // let the event out to our main handler and loop back into this command when it's done } } else { if (!Button()) inState.SetPC(this); else { #if TB_FlushEventsAllTheFeckinTime ::FlushEvents(kUserInputEventMask,0L); #endif } } }