/* virtual */ OP_STATUS Google2011NetworkApiResponseParser::EnterObject() { if (m_state_stack_size == 0) return PushState(MAIN_OBJECT); else if (m_state_stack_size == 2 && m_state_stack[1] == LOCATION) return PushState(LOCATION_OBJECT); else return PushState(UNKNOWN_OBJECT); }
void AudioView::Cut() { ClearClipboard(); TrackList *tracks = GetTracks(); VTrack *n = tracks->First(); VTrack *dest = 0; while(n) { if (n->selected) { n->Cut(sel0, sel1, &dest); if (dest) clipboard->Add(dest); } n = tracks->Next(); } clipLen = (sel1 - sel0); sel1 = sel0; PushState(); FixScrollbars(); REDRAW(trackPanel); REDRAW(rulerPanel); UpdateMenus(); }
void AudioView::Paste() { if (sel0 != sel1) Clear(); wxASSERT(sel0 == sel1); double tsel = sel0; TrackList *tracks = GetTracks(); VTrack *n = tracks->First(); VTrack *c = clipboard->First(); while(n && c) { if (n->selected) { n->Paste(tsel, c); c = clipboard->Next(); } n = tracks->Next(); } // TODO: What if we clicked past the end of the track? sel0 = tsel; sel1 = tsel + clipLen; PushState(); FixScrollbars(); REDRAW(trackPanel); REDRAW(rulerPanel); UpdateMenus(); }
void AudioView::Pitch() { VTrack *t; bool success = false; TrackList *tracks = GetTracks(); t = tracks->First(); while(t) { if (t->selected && t->GetKind() == VTrack::Wave) { NoteTrack *note = PitchExtract((WaveTrack *)t, &((AudioDoc *)GetDocument())->dirManager); if (note) { success = true; tracks->Add(note); } } t = tracks->Next(); } if (success) { PushState(); FixScrollbars(); REDRAW(trackPanel); REDRAW(rulerPanel); } }
bool AudioView::ProcessEvent(wxEvent& event) { if (event.GetEventType() == wxEVT_COMMAND_MENU_SELECTED && event.GetId() >= FirstEffectID && event.GetId() < FirstEffectID + numEffects) { Effect *f = Effect::GetEffect(event.GetId() - FirstEffectID); TrackList *tracks = GetTracks(); VTrack *t = tracks->First(); while(t) { if (t->selected && t->GetKind() == (VTrack::Wave)) { f->DoInPlaceEffect((WaveTrack *)t, sel0, sel1); } t = tracks->Next(); } PushState(); FixScrollbars(); REDRAW(trackPanel); REDRAW(rulerPanel); // This indicates we handled the event. return true; } return wxView::ProcessEvent(event); }
void AudioView::ImportMIDI() { wxString fileName = wxFileSelector("Select a MIDI File...", "", // Path "", // Name ".mid", // Extension "*.mid", // Wildcard 0, // Flags GetFrame()); // Parent if (fileName == "") return; NoteTrack *newTrack = new NoteTrack(&((AudioDoc *)GetDocument())->dirManager); if (::ImportMIDI(fileName, newTrack)) { SelectNone(); GetTracks()->Add(newTrack); newTrack->selected = true; PushState(); FixScrollbars(); REDRAW(trackPanel); REDRAW(rulerPanel); } }
virtual void Draw(BRect updateRect) { BRegion region; region.Include(BRect(20, 20, 40, 40)); region.Include(BRect(30, 30, 80, 80)); ConstrainClippingRegion(®ion); SetHighColor(55, 255, 128, 255); FillRect(BRect(0, 0, 100, 100)); PushState(); SetOrigin(15, 15); ConstrainClippingRegion(®ion); SetHighColor(155, 255, 128, 255); FillRect(BRect(0, 0, 100, 100)); // ConstrainClippingRegion(NULL); SetHighColor(0, 0, 0, 255); StrokeLine(BPoint(2, 2), BPoint(80, 80)); SetHighColor(255, 0, 0, 255); StrokeLine(BPoint(2, 2), BPoint(4, 2)); PopState(); SetHighColor(0, 0, 0, 255); StrokeLine(BPoint(4, 2), BPoint(82, 80)); }
void NetListView::FrameResized(float width, float height) { BListView::FrameResized(width, height); //Ensure the bevel on the right is drawn properly if(width < oldWidth) oldWidth = width; PushState(); BRect invalRect(oldWidth, 0, oldWidth, height); ConvertFromParent(&invalRect); BRegion lineRegion(invalRect); ConstrainClippingRegion(&lineRegion); Draw(invalRect); oldWidth = width; PopState(); //Do word wrapping BFont curFont; GetFont(&curFont); float itemWidth = Bounds().Width(); float wrapWidth = (itemWidth - 6)/curFont.Size(); for(int itemNum = 0; itemNum < CountItems(); itemNum++) { NetListItem* item = (NetListItem*)(Items()[itemNum]); item->SetWidth(itemWidth); item->CalcWordWrap(wrapWidth); } //DoForEach(UpdateItem, (void*)this); Invalidate(); BListView::FrameResized(width, height); }
void AudacityProject::Trim(wxEvent & event) { if (mViewInfo.sel0 >= mViewInfo.sel1) return; TrackListIterator iter(mTracks); VTrack *n = iter.First(); while (n) { if (n->GetSelected()) { //Delete the section before the left selector n->Clear(n->GetOffset(), mViewInfo.sel0); if (mViewInfo.sel0 > n->GetOffset()) n->SetOffset(mViewInfo.sel0); //Delete the section after the right selector n->Clear(mViewInfo.sel1, n->GetMaxLen()); } n = iter.Next(); } FixScrollbars(); mTrackPanel->Refresh(false); PushState(_("Trim file to selection")); }
void AudacityProject::OnImportMIDI(wxCommandEvent & event) { wxString path = gPrefs->Read("/DefaultOpenPath",::wxGetCwd()); wxString fileName = wxFileSelector(_("Select a MIDI file..."), path, // Path "", // Name "", // Extension _("All files (*.*)|*.*|" "MIDI files (*.mid)|*.mid|" "Allegro files (*.gro)|*.gro"), 0, // Flags this); // Parent if (fileName != "") { path =::wxPathOnly(fileName); gPrefs->Write("/DefaultOpenPath", path); NoteTrack *newTrack = new NoteTrack(&mDirManager); if (::ImportMIDI(fileName, newTrack)) { SelectNone(); mTracks->Add(newTrack); newTrack->SetSelected(true); PushState(wxString::Format(_("Imported MIDI from '%s'"), fileName.c_str())); FixScrollbars(); mTrackPanel->Refresh(false); } } }
void BBox::Draw(BRect updateRect) { if (!IsVisible() || fBorder == B_NO_BORDER) return; e_theme_engine *theme = get_current_theme_engine(); if (theme == NULL || theme->get_border_margins == NULL || theme->draw_border == NULL) return; float l = 0, t = 0, r = 0, b = 0; theme->get_border_margins(theme, this, &l, &t, &r, &b, fBorder, PenSize()); BRect rect = Frame().OffsetToSelf(B_ORIGIN); if (!(fLabelView == NULL || fLabelView->Frame().Width() <= 0 || fLabelView->Frame().Height() < t)) rect.top += (fLabelView->Frame().Height() - t) / 2.f; PushState(); BRegion clipping(updateRect); if (!(fLabelView == NULL || fLabelView->Frame().IsValid() == false)) clipping.Exclude(fLabelView->Frame()); ConstrainClippingRegion(&clipping); if (clipping.CountRects() > 0) theme->draw_border(theme, this, rect, fBorder, PenSize()); PopState(); }
void GameEngine::Escaper() //this should be done in seperate class if I'm correct? { if(event.type == ALLEGRO_EVENT_KEY_DOWN) //this thing shouldn't be here imo { switch(event.keyboard.keycode) { case ALLEGRO_KEY_ESCAPE: if (IsGameStateActive()) { PushState(menuState); menuState->SwitchToMenu("Wave Menu"); } else if (menuState->CurrentMenu->GetName() == "Wave Menu") { PopState(); } break; case ALLEGRO_KEY_B: //this should seriously be left somewhere else, or this method should change its name if (IsGameStateActive()) { if (collisionDetector->IsHitboxDisplayEnabled()) collisionDetector->EnableHitboxDisplay(false); else collisionDetector->EnableHitboxDisplay(true); } break; } } else if (event.type == ALLEGRO_EVENT_DISPLAY_CLOSE) Quit(); }
GameEngine::GameEngine(int argc, char **argv) { m_running = true; // pass in glfwGetPrimaryMonitor() to first null for fullscreen window = glfwCreateWindow(1024, 768, WINDOWTITLE, NULL, NULL); if (!window) { fprintf(stderr, "Failed to open GLFW window. If you have an Intel GPU, they are not 3.3 compatible. Try the 2.1 version of the tutorials.\n"); glfwTerminate(); exit(EXIT_FAILURE); } glfwMakeContextCurrent(window); // Currently just starts it with the PlayState PlayState *state = new PlayState(window); PushState(state); ChangeState(state); //Callbacks glfwSetKeyCallback(window, key_callback); glfwSetCursorPosCallback(window, mouse_motion); glfwSetMouseButtonCallback(window, mouse_button); glfwSetScrollCallback(window, mouse_scroll); }
void VideoEngine::DrawGrid(float x, float y, float x_step, float y_step, const Color &c) { PushState(); Move(0, 0); float x_max = _current_context.coordinate_system.GetRight(); float y_max = _current_context.coordinate_system.GetBottom(); std::vector<GLfloat> vertices; int32 num_vertices = 0; for(; x <= x_max; x += x_step) { vertices.push_back(x); vertices.push_back(_current_context.coordinate_system.GetBottom()); vertices.push_back(x); vertices.push_back(_current_context.coordinate_system.GetTop()); num_vertices += 2; } for(; y < y_max; y += y_step) { vertices.push_back(_current_context.coordinate_system.GetLeft()); vertices.push_back(y); vertices.push_back(_current_context.coordinate_system.GetRight()); vertices.push_back(y); num_vertices += 2; } glColor4fv(&c[0]); DisableTexture2D(); EnableVertexArray(); glVertexPointer(2, GL_FLOAT, 0, &(vertices[0])); glDrawArrays(GL_LINES, 0, num_vertices); PopState(); }
bool Mind::EndState() { if (!_stateQueue.empty()) { // Don't destroy the State object this round _recycleBin = _stateQueue.front(); DM_LOG(LC_AI, LT_INFO)LOGSTRING("Ending State %s (%s)\r", _recycleBin->GetName().c_str(), _owner.GetEntity()->name.c_str()); // Remove the current state from the queue _stateQueue.pop_front(); // Trigger a stateswitch next round in any case _switchState = true; } if (_stateQueue.empty()) { // No states left, add the default state at least PushState(STATE_DEFAULT); } // Return TRUE if there are additional states left return true; }
void TExportZone::DrawInMarker(BRect updateRect) { // Set up environment PushState(); BPoint drawPt; // Draw left marker if (updateRect.Intersects(m_InRect) ) { // Draw indicator in new location drawPt.Set(m_InRect.left, m_InRect.top); DrawBitmap(m_InMarker, drawPt); } // Draw right marker if (updateRect.Intersects(m_OutRect) ) { // Draw indicator in new location drawPt.Set(m_OutRect.left, m_OutRect.top); DrawBitmap(m_OutMarker, drawPt); } // Restore environment PopState(); }
void AppGroupView::_DrawCloseButton(const BRect& updateRect) { PushState(); BRect closeRect = fCloseRect; rgb_color base = ui_color(B_PANEL_BACKGROUND_COLOR); float tint = B_DARKEN_2_TINT; if (fCloseClicked) { BRect buttonRect(closeRect.InsetByCopy(-4, -4)); be_control_look->DrawButtonFrame(this, buttonRect, updateRect, base, base, BControlLook::B_ACTIVATED | BControlLook::B_BLEND_FRAME); be_control_look->DrawButtonBackground(this, buttonRect, updateRect, base, BControlLook::B_ACTIVATED); tint *= 1.2; closeRect.OffsetBy(1, 1); } base = tint_color(base, tint); SetHighColor(base); SetPenSize(2); StrokeLine(closeRect.LeftTop(), closeRect.RightBottom()); StrokeLine(closeRect.LeftBottom(), closeRect.RightTop()); PopState(); }
bool Game::Init(IGameState* state) { if (SDL_Init(SDL_INIT_EVERYTHING) < 0) { std::cerr << SDL_GetError() << std::endl; return false; } window = SDL_CreateWindow(TITLE, SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, screenWidth, screenHeight, SDL_WINDOW_SHOWN); if (window == NULL) { std::cerr << SDL_GetError() << std::endl; return false; } renderer = SDL_CreateRenderer(window, NULL, SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC); if (renderer == NULL) { std::cerr << SDL_GetError(); return false; } srand(time(NULL)); PushState(state); return true; }
void AudacityProject::OnDuplicate(wxCommandEvent & event) { TrackListIterator iter(mTracks); VTrack *n = iter.First(); VTrack *dest = 0; TrackList newTracks; while (n) { if (n->GetSelected()) { n->Copy(mViewInfo.sel0, mViewInfo.sel1, &dest); if (dest) { dest->Init(*n); dest->SetOffset(wxMax(mViewInfo.sel0, n->GetOffset())); newTracks.Add(dest); } } n = iter.Next(); } TrackListIterator nIter(&newTracks); n = nIter.First(); while (n) { mTracks->Add(n); n = nIter.Next(); } PushState(_("Duplicated")); FixScrollbars(); mTrackPanel->Refresh(false); }
void AudacityProject::Cut(wxCommandEvent & event) { ClearClipboard(); TrackListIterator iter(mTracks); VTrack *n = iter.First(); VTrack *dest = 0; while (n) { if (n->GetSelected()) { n->Cut(mViewInfo.sel0, mViewInfo.sel1, &dest); if (dest) msClipboard->Add(dest); } n = iter.Next(); } msClipLen = (mViewInfo.sel1 - mViewInfo.sel0); msClipProject = this; mViewInfo.sel1 = mViewInfo.sel0; PushState(_("Cut to the clipboard")); FixScrollbars(); mTrackPanel->Refresh(false); }
void AudacityProject::OnAlign(wxCommandEvent & event) { double avg = 0.0; int num = 0; TrackListIterator iter(mTracks); VTrack *t = iter.First(); while (t) { if (t->GetSelected()) { avg += t->GetOffset(); num++; } t = iter.Next(); } if (num) { avg /= num; TrackListIterator iter2(mTracks); t = iter2.First(); while (t) { if (t->GetSelected()) t->SetOffset(avg); t = iter2.Next(); } } PushState(_("Aligned tracks")); mTrackPanel->Refresh(false); }
void NASReader::PushFeature( const char *pszElement, const Attributes &attrs ) { int iClass; /* -------------------------------------------------------------------- */ /* Find the class of this element. */ /* -------------------------------------------------------------------- */ for( iClass = 0; iClass < GetClassCount(); iClass++ ) { if( EQUAL(pszElement,GetClass(iClass)->GetElementName()) ) break; } /* -------------------------------------------------------------------- */ /* Create a new feature class for this element, if there is no */ /* existing class for it. */ /* -------------------------------------------------------------------- */ if( iClass == GetClassCount() ) { CPLAssert( !IsClassListLocked() ); GMLFeatureClass *poNewClass = new GMLFeatureClass( pszElement ); AddClass( poNewClass ); } /* -------------------------------------------------------------------- */ /* Create a feature of this feature class. */ /* -------------------------------------------------------------------- */ GMLFeature *poFeature = new GMLFeature( GetClass( iClass ) ); /* -------------------------------------------------------------------- */ /* Create and push a new read state. */ /* -------------------------------------------------------------------- */ GMLReadState *poState; poState = new GMLReadState(); poState->m_poFeature = poFeature; PushState( poState ); /* -------------------------------------------------------------------- */ /* Check for gml:id, and if found push it as an attribute named */ /* gml_id. */ /* -------------------------------------------------------------------- */ int nFIDIndex; XMLCh anFID[100]; tr_strcpy( anFID, "gml:id" ); nFIDIndex = attrs.getIndex( anFID ); if( nFIDIndex != -1 ) { char *pszFID = tr_strdup( attrs.getValue( nFIDIndex ) ); SetFeatureProperty( "gml_id", pszFID ); CPLFree( pszFID ); } }
void tGameEngine::ChangeState(tState * pState) { if (m_States.empty() == false) { PopState(); } PushState(pState); }
void Mind::Think() { // Clear the recyclebin, it might hold a finished state from the last frame _recycleBin = StatePtr(); // greebo: We do not check for NULL pointers in the owner at this point, // as this method is called by the owner itself, it _has_ to exist. idAI* owner = _owner.GetEntity(); assert(owner != NULL); if (_stateQueue.empty()) { // We start with the idle state PushState(owner->backboneStates[ai::ERelaxed]); } // At this point, we MUST have a State assert(_stateQueue.size() > 0); const StatePtr& state = _stateQueue.front(); // Thinking DM_LOG(LC_AI, LT_INFO)LOGSTRING("Mind is thinking... %s\r", owner->name.c_str()); // Should we switch states (i.e. initialise a new one)? if (_switchState) { // Clear the flag _switchState = false; // Initialise the state, this will put the Subsystem Tasks in place state->Init(owner); } if (!_switchState) { // Let the State do its monitoring task state->Think(owner); } // Try to perform the subsystem tasks, skipping inactive subsystems // Maximum number of tries is SubsystemCount. for (int i = 0; i < static_cast<int>(SubsystemCount); i++) { // Increase the iterator and wrap around, if necessary _subsystemIterator = static_cast<SubsystemId>( (static_cast<int>(_subsystemIterator) + 1) % static_cast<int>(SubsystemCount) ); // Subsystems return TRUE when their task was executed if (owner->GetSubsystem(_subsystemIterator)->PerformTask()) { // Task performed, break, iterator will be increased next round break; } } }
void Mind::PushState( const idStr &stateName ) { // Get a new state with the given name StatePtr newState = StateLibrary::Instance().CreateInstance( stateName.c_str() ); if( newState != NULL ) { PushState( newState ); } else { gameLocal.Error( "Mind: Could not push state %s", stateName.c_str() ); } }
void TCueSheetTimeView::Draw(BRect updateRect) { // Set up environment PushState(); const BRect bounds = Bounds(); BPoint startPt, endPt; // Draw TimeRect frame SetHighColor(kLightGrey); FillRect(bounds); // Draw black outline SetHighColor(kBlack); startPt.Set(bounds.left, bounds.top); endPt.Set(bounds.left, bounds.bottom); StrokeLine(startPt, endPt); startPt.Set(bounds.right, bounds.top); endPt.Set(bounds.right, bounds.bottom); StrokeLine(startPt, endPt); // Draw shadow SetHighColor(kMediumGrey); startPt.Set(bounds.right-1, bounds.top); endPt.Set(bounds.right-1, bounds.bottom); StrokeLine(startPt, endPt); startPt.Set(bounds.right-1, bounds.bottom); endPt.Set(bounds.left+1, bounds.bottom); StrokeLine(startPt, endPt); // Draw highlight SetHighColor(kWhite); startPt.Set(bounds.left+1, bounds.bottom - 2); endPt.Set(bounds.left+1, bounds.top); StrokeLine(startPt, endPt); startPt.Set(bounds.left+1, bounds.top); endPt.Set(bounds.right-2, bounds.top); StrokeLine(startPt, endPt); // Draw cue sheet start time BFont font; GetFont(&font); SetFont(be_bold_font); SetHighColor(kBlack); BPoint textPt; char timeStr[256]; int32 startTime = m_CueSheetWindow->GetCueSheetView()->StartTime(); textPt.Set(bounds.left + 9, bounds.top + 16); TimeToString(startTime, m_CueSheetWindow->GetCueSheetView()->GetTimeFormat(), timeStr, FALSE); DrawString(timeStr, textPt); // Restore environment PopState(); }
NS_IMETHODIMP nsThebesRenderingContext::PushTranslation(PushedTranslation* aState) { PR_LOG(gThebesGFXLog, PR_LOG_DEBUG, ("## %p nsTRC::PushTranslation\n", this)); // XXX this is slow! PushState(); return NS_OK; }
void GameEngine::Initialize(const SDL_Rect& screenSize) { std::cout << "GameEngine::Initialize" << std::endl; _socket = ClientSocket("0.0.0.0", "5001"); SDL_Init(SDL_INIT_EVERYTHING); srand((unsigned int)time(NULL)); // Soundstuff int audioRate = 22050; Uint16 audioFormat = AUDIO_S16SYS; int audioChannels = 2; int audioBuffers = 4096; if(Mix_OpenAudio(audioRate, audioFormat, audioChannels, audioBuffers) != 0) { std::cerr << "Unable to initialize audio: " << Mix_GetError() << std::endl; throw Mix_GetError(); } // Activate anti-aliasing SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 1); // Set AA level to 2 SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, 2); if (SDL_SetVideoMode(screenSize.x, screenSize.y, 32, SDL_HWSURFACE | SDL_GL_DOUBLEBUFFER | SDL_OPENGL) == NULL) { /* Ugly hack to make it work even if the system doesn't support multisampling. [FIXME]*/ SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 0); SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, 0); if (SDL_SetVideoMode(screenSize.x, screenSize.y, 32, SDL_HWSURFACE | SDL_GL_DOUBLEBUFFER | SDL_OPENGL) == NULL) { throw SDL_GetError(); } } glViewport(0, 0, screenSize.x, screenSize.y); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho(0, screenSize.x, 0, screenSize.y, 1, -1); glMatrixMode(GL_MODELVIEW); glClearColor(0, 0.1f, 0, 1.0f); glClearDepth(1.0f); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glAlphaFunc(GL_GREATER, 0.1f); PushState(new GSMain()); }
void Mind::SwitchState( const StatePtr &state ) { // greebo: Switch the state without destroying the current State object immediately if( _stateQueue.size() > 0 ) { // Store the shared_ptr in the temporary container _recycleBin = _stateQueue.front(); // Remove the first element from the queue _stateQueue.pop_front(); //PrintStateQueue("pop"); } // Add the new task PushState( state ); }
bool AudacityProject::ProcessEvent(wxEvent & event) { int numEffects = Effect::GetNumEffects(false); int numPlugins = Effect::GetNumEffects(true); Effect *f = NULL; if (event.GetEventType() == wxEVT_COMMAND_MENU_SELECTED) { // Builtin Effects if(event.GetId() >= FirstEffectID && event.GetId() < FirstEffectID + numEffects) { f = Effect::GetEffect(event.GetId() - FirstEffectID, false); } else if(event.GetId() >= FirstPluginID && event.GetId() < FirstPluginID + numPlugins) { f = Effect::GetEffect(event.GetId() - FirstPluginID, true); } else { if(HandleMenuEvent(event)) return true; } } if (f) { TrackListIterator iter(mTracks); VTrack *t = iter.First(); int count = 0; while (t) { if (t->GetSelected() && t->GetKind() == (VTrack::Wave)) count++; t = iter.Next(); } if (count == 0 || mViewInfo.sel0 == mViewInfo.sel1) { wxMessageBox(_("No audio data is selected.")); return true; } if (f->DoEffect(this, mTracks, mViewInfo.sel0, mViewInfo.sel1)) { PushState(_("Applied an effect.")); // maybe more specific? FixScrollbars(); mTrackPanel->Refresh(false); } else { // TODO: undo the effect if necessary? } // This indicates we handled the event. return true; } return wxFrame::ProcessEvent(event); }