/* Right click - get info about the object. */ HRESULT INTERACTIVE::RightClick(const int x, const int y) { Gdiplus::PointF hit_position(x - static_cast<Gdiplus::REAL>(video_position.left), y - static_cast<Gdiplus::REAL>(video_position.top)); int i = DetectCollision(hit_position); if(i){ // Play audio hr = audio_media_control->Stop(); std::string source = objects[i-1].caption_sound_path; hr = audio_graph->RenderFile(string2wstring(source).c_str(), NULL); HRLog("IGraphBuilder.RenderFile() - additional audio", hr, false); hr = audio_media_control->Run(); if(hr){ OAFilterState filter_state; hr = video_media_control->GetState(INFINITE, &filter_state); HRLog("IMediaControl.GetState - additional audio play", hr, false); } // Display the caption caption_displayed = true; BMP_mix->Clear(key_color); // Bitmap for video mixing DrawString(hit_position, objects[i-1].caption.c_str()); } DrawOutlines(); BlendText(); return hr; }
/*Starts pointing a new object.*/ HRESULT INTERACTIVE::NPressed() { temp_points[temp_points_count] = last_point; temp_points_count++; BMP_mix->Clear(key_color); DrawOutlines(); BlendText(); return S_OK; }
/*End pointing an object.*/ HRESULT INTERACTIVE::DPressed() { if (temp_points_count <= 0) return S_FALSE; temp_points_count--; BMP_mix->Clear(key_color); DrawOutlines(); BlendText(); return S_OK; }
void RenderGui(){ DrawOutlines(); DrawMsgLog(); DrawStats(); io::flip(); }
/* Response to the move of the cursor - if there is a object hit, object is captioned. */ HRESULT INTERACTIVE::MouseMove(const int x,const int y) { Gdiplus::PointF hit_position(x - static_cast<Gdiplus::REAL>(video_position.left), y - static_cast<Gdiplus::REAL>(video_position.top)); last_point.X = hit_position.X; last_point.Y = hit_position.Y; int i = DetectCollision(hit_position); if(i != 0 && i != last_active_object){ last_active_object = i; caption_displayed = false; BMP_mix->Clear(key_color); DrawString(hit_position, objects[i-1].name.c_str()); DrawOutlines(); BlendText(); } else if (last_active_object != 0 && i == 0 && caption_displayed != true){ BMP_mix->Clear(key_color); last_active_object = 0; DrawOutlines(); BlendText(); } return S_OK; }
/*Fix current cursor point.*/ HRESULT INTERACTIVE::FPressed() { if(temp_points_count <= 2) { DisplayText(L"No polygon exists"); return S_FALSE; } Gdiplus::GraphicsPath boundaries; boundaries.AddPolygon(temp_points, temp_points_count); std::wstring name(L"Object "); name.append(boost::lexical_cast<std::wstring, std::size_t>(objects.size())); std::vector<state_changes> changes; state_changes change = {"No_change", 0, 0}; changes.push_back(change); objects.push_back(SCENE_OBJECT(&boundaries, name, L"!caption!", "!sound_path!", "!caption_sound_path!", changes, false)); temp_points_count = 0; name.append(L" saved."); BMP_mix->Clear(key_color); DrawOutlines(); DisplayText(name); return S_OK; }
/* Constructor. */ INTERACTIVE::INTERACTIVE(const CMarkup * original_script) : SCENE(original_script) { last_active_object = 0; caption_displayed = false; if(!scene_created) return; if(!CreateObjects()) return; if(Play() != S_OK) return; // Editor setup outliner = new Gdiplus::Pen(Gdiplus::Color(0,255,0),1.5f); nowliner = new Gdiplus::Pen(Gdiplus::Color(0,0,255),1.5f); temp_points_count = 0; temp_points = new Gdiplus::Point[1000]; last_point = Gdiplus::Point(0,0); DrawOutlines(); BlendText(); PostSceneCreated(); }