Example #1
0
void CTooltip::Draw() 
{
	float z = 900.f; // TODO: Find a nicer way of putting the tooltip on top of everything else

	if (GetGUI())
	{
		CGUISpriteInstance *sprite;
		GUI<CGUISpriteInstance>::GetSettingPointer(this, "sprite", sprite);

		// Normally IGUITextOwner will handle this updating but since SetupText can modify the position
		// we need to call it now *before* we do the rest of the drawing
		if (!m_GeneratedTextsValid)
		{
			SetupText();
			m_GeneratedTextsValid = true;
		}

		GetGUI()->DrawSprite(*sprite, 0, z, m_CachedActualSize);

		CColor color;
		GUI<CColor>::GetSetting(this, "textcolor", color);

		// Draw text
		IGUITextOwner::Draw(0, color, m_CachedActualSize.TopLeft(), z+0.1f);
	}
}
void CKSPlugInGUIPane::Init()
{
	mpPane = ge::IPane::Create();
	mpPane->SetSize(ge::SSize(396, 124));
	mpPane->SetBackgroundColour(ge::SRGB(0, 0, 0));
	
	
	// Max add new tool bar pane to mpPane pane here
	
	//--------------------------------------------
	// Track_File_Browser
	// This is a container that scrools when KS plays
	mpToolbar = new CPlugin_Toolbar(this, GetGUI());
//	mpToolbar->SetInfo(miSectionID, miInsertIndex);
	mpToolbar->Init();
	mpPane->AddControl(mpToolbar->GetPane(), ge::SPos(0, 0));
	
	
	// Top label
	CreateBitmap(ge::IControl::giNoID, IDB_Back_Plug_File_Browser_Left, ge::SPos(0, 24));
	ge::IBitmap* pBmp =CreateBitmap(ge::IControl::giNoID, IDB_Back_Plug_File_Browser_Center, ge::SPos(16, 24));
	pBmp->SetSize(ge::SSize( 365 , 100  ));
	
	CreateBitmap(ge::IControl::giNoID, IDB_Back_Plug_File_Browser_Right, ge::SPos(365+16, 24));

	mpEffectPane = new CKSPlugInEffectPane(this, GetGUI());
	mpEffectPane->Init();
	mpPane->AddControl(mpEffectPane->GetPane(), ge::SPos(0, 24));
}
Example #3
0
CPos IGUIObject::GetMousePos() const
{
	if (GetGUI())
		return GetGUI()->m_MousePos;

	return CPos();
}
Example #4
0
LRESULT CLogicView::ToolbarReaction(ButtonItem* Bnt){
	switch(Bnt->m_Alias){
 
    case CM_DELETE_LOGIC:
		{
			CLogicItem* Item = (CLogicItem*)m_Toolbar.m_Owner;
			//发信息给大脑,然后大脑生成处理好以后再返回处理结果
			ePipeline Msg(GUI_LOGIC_OPERATE);		
			Msg.PushInt(DEL_LOGIC);
			Msg.PushString(Item->m_LogicName);
			
			GetGUI()->SendMsgToBrainFocuse(Msg);

		}
		break;
    case CM_CLEAR_LOGIC:
		{
			//发信息给大脑,然后大脑生成处理好以后再返回处理结果
			ePipeline Msg(GUI_LOGIC_OPERATE);		
			Msg.PushInt(CLEAR_LOGIC);
			
			GetGUI()->SendMsgToBrainFocuse(Msg);
		}
		break;
	}
	return 0;
}
void CKSMixerGUIPane::Init()
{


    mpPane = ge::IPane::Create();
    mpPane->SetBackgroundColour(ge::SRGB(0, 0, 0));
    mpPane->SetSize(gMix);



    //--------------------------------------------
    // Scroll pane holds the channels
    mpMix_Scroll = new CMix_Scroll(this, GetGUI());
    mpMix_Scroll->SetInfo();
    mpMix_Scroll->Init();
    mpPane->AddControl(mpMix_Scroll->GetPane(), ge::SPos(0, 0));

    Create_Mix_ScrollBar_Horizontal();


    tint32 iPosX = gMix.iCX -64;

    //--------------------------------------------
    // Master
    mpMix_Master = new CMix_Master(this, GetGUI());
    mpMix_Master_Out_Menu.iItemCount = 3;
    mpMix_Master_Out_Menu.pItems[0] = ge::IPopupMenu::SMenuItem((const tchar*)"12",	0,	NULL);
    mpMix_Master_Out_Menu.pItems[1] = ge::IPopupMenu::SMenuItem((const tchar*)"34",	1,	NULL);
    mpMix_Master_Out_Menu.pItems[2] = ge::IPopupMenu::SMenuItem((const tchar*)"56",	2,	NULL);
    mpMix_Master->SetInfo(mpMix_Master_Out_Menu);
    mpMix_Master->Init();
    mpPane->AddControl(mpMix_Master->GetPane(), ge::SPos(iPosX, 0));
    mpMix_Master->GetPane()->StickTo(ge::IControl::PosTopRight, ge::SPos(0, 0));

    iPosX -= 6;
    //--------------------------------------------
    // Busses
    tint32 iBusStickToPos = -70;
    for(tint32 i=0; i<giNumber_Of_Busses; i++) {
        iPosX -= 64;
        mpMix_Busses[i] = new CMix_Buss(this, GetGUI());
        tint32 iTimerID = i + giTimerID_MixFirstBus_ScrollPane;
        mpMix_Busses[i]->SetInfo(giNumber_Of_Busses - i  - 1, iTimerID);
        mpMix_Busses[i]->Init();

        mpPane->AddControl(mpMix_Busses[i]->GetPane(), ge::SPos(iPosX, 0));
        mpMix_Busses[i]->GetPane()->StickTo(ge::IControl::PosTopRight, ge::SPos(iBusStickToPos, 0));
        iBusStickToPos -= 64;
    }

    //--------------------------------------------
    // Backdrop under file browser
    ge::IBitmap* pBmp = CreateBitmap(ge::IControl::giNoID, IDB_Back_Mix_Bottom, ge::SPos(gMix.iCX - 332, gMix.iCY - 14));
    pBmp->StickTo(ge::IControl::PosBottomRight, ge::SPos(0, 0));
    pBmp->SetSize(ge::SSize( 332 , 14  ));



}
Example #6
0
void IPlugChunks::PresetsChangedByHost()
{
  TRACE;
  IMutexLock lock(this);

  if(mMSlider)
    mMSlider->SetState(mSteps);

  if(GetGUI())
    GetGUI()->SetAllControlsDirty();
}
void CKSImportGUIPane::Init()
{
    mpPane = ge::IPane::Create();
    mpPane->SetSize(ge::SSize(424,424));
    CreateBitmap(ge::IControl::giNoID, IDB_Back_Import, ge::SPos(0, 0));

    mpPop = NULL;

    //-------------------------------------------------
    // Scroll pane viewing the content in a "Folder"
    mpImport_File_Browser = new CKS_Import_File_Browser(this, GetGUI());
    mpImport_File_Browser->SetInfo();
    mpImport_File_Browser->Init();
    mpPane->AddControl(mpImport_File_Browser->GetPane(), ge::SPos(8, 39));
    Create_File_Browser_ScrollBar();

    //-------------------------------------------------
    // Scroll pane viewing a list of files to add to te project
    mpImport_Files = new CKS_Import_Files(this, GetGUI());
    mpImport_Files->SetInfo();
    mpImport_Files->Init();
    mpPane->AddControl(mpImport_Files->GetPane(), ge::SPos(216, 39));
    Create_File_ScrollBar();


    CreateButton(giCtrl_Remove_Import, IDB_Button_Move, ge::SPos(195, 345), false);
    CreateButton(giCtrl_Add_Import, IDB_Button_Add, ge::SPos(195, 369), false);
    // Stop
    CreateButton(giCtrl_Stop_Import, IDB_Button_Stop, ge::SPos(195, 369+24), false);
    // Play
    Create2StateButton(giCtrl_Play_Import, IDB_Button_Play, ge::SPos(195+28, 369+24), true);


    // Cancel / Export
    CreateButton(giCtrl_Cancel_Import, IDB_Button_Cancel, ge::SPos(292, 400), false);
    CreateButton(giCtrl_Import, IDB_Button_Import, ge::SPos(292 + 64, 400), false);

    tchar psz[1024];
    CKSPlugIn* pPlugIn = dynamic_cast<CKSPlugIn*>(GetPlugIn());
    //IFile::GetSystemDirectory(IFile::SystemDirDesktop, psz);
    pPlugIn->GetDefaultProjectFolder(psz);
    BrowseToDir(std::string(psz));

    dynamic_cast<CKSPlugIn*>(GetGUI()->GetPlugIn())->SetPreviewCallback(dynamic_cast<CPreviewCallback*>(this));

    ge::IText* pText = CreateDisplay(giControlType, ge::SPos(96, 333+22), ge::SSize(100, 12), CreateFont(Generic128, IDB_Minix_Tight, ge::SRGB(10, 10, 10)), false);
    pText->SetHorzAlignment(ge::IText::HorzAlignLeft);
    pText = CreateDisplay(giControlBitDepth, ge::SPos(96, 347+22), ge::SSize(100, 12), CreateFont(Generic128, IDB_Minix_Tight, ge::SRGB(10, 10, 10)), false);
    pText->SetHorzAlignment(ge::IText::HorzAlignLeft);
    pText = CreateDisplay(giControlSampleRate, ge::SPos(96, 361+22), ge::SSize(100, 12), CreateFont(Generic128, IDB_Minix_Tight, ge::SRGB(10, 10, 10)), false);
    pText->SetHorzAlignment(ge::IText::HorzAlignLeft);
    pText = CreateDisplay(giControlChannels, ge::SPos(96, 375+22), ge::SSize(100, 12), CreateFont(Generic128, IDB_Minix_Tight, ge::SRGB(10, 10, 10)), false);
    pText->SetHorzAlignment(ge::IText::HorzAlignLeft);
} // Init
Example #8
0
void FaceDetectorModule::SetupGUIVariables(){
    GetGUI().AddWindow("Face Detector", ivec2(300, 195));
    params::InterfaceGlRef facesWindow = GetGUI().GetWindow("Face Detector");
    facesWindow->setPosition(ivec2(515, 5));
    
    //Settings
    facesWindow->addParam("Module Enabled", &enabled).keyIncr("e");
    facesWindow->addSeparator("All");
    facesWindow->addParam("Scale", &imageScale).min(0.01).max(1.00);
    
    
}
void IPlugVST3Plugin::ResizeGraphics(int w, int h)
{
  if (GetGUI())
  {
    viewsArray.at(0)->resize(w, h);
  }
}
Example #10
0
void IGUIObject::RegisterScriptHandler(const CStr& Action, const CStr& Code, CGUI* pGUI)
{
	if(!GetGUI())
		throw PSERROR_GUI_OperationNeedsGUIObject();

	JSContext* cx = pGUI->GetScriptInterface()->GetContext();
	JSAutoRequest rq(cx);
	JS::RootedValue globalVal(cx, pGUI->GetGlobalObject());
	JS::RootedObject globalObj(cx, &globalVal.toObject());

	const int paramCount = 1;
	const char* paramNames[paramCount] = { "mouse" };

	// Location to report errors from
	CStr CodeName = GetName()+" "+Action;

	// Generate a unique name
	static int x = 0;
	char buf[64];
	sprintf_s(buf, ARRAY_SIZE(buf), "__eventhandler%d (%s)", x++, Action.c_str());

	JS::CompileOptions options(cx);
	options.setFileAndLine(CodeName.c_str(), 0);
	options.setCompileAndGo(true);

	JS::RootedFunction func(cx, JS_CompileFunction(cx, globalObj,
		buf, paramCount, paramNames, Code.c_str(), Code.length(), options));

	if (!func)
		return; // JS will report an error message

	JS::RootedObject funcObj(cx, JS_GetFunctionObject(func));
	SetScriptHandler(Action, funcObj);
}
Example #11
0
bool IGUIObject::MouseOver()
{
	if (!GetGUI())
		throw PSERROR_GUI_OperationNeedsGUIObject();

	return m_CachedActualSize.PointInside(GetMousePos());
}
Example #12
0
void IPlugVST::ResizeGraphics(int w, int h)
{
  IGraphics* pGraphics = GetGUI();
  if (pGraphics) {
    mEditRect.left = mEditRect.top = 0;
    mEditRect.right = pGraphics->Width();
    mEditRect.bottom = pGraphics->Height();
  }
}
Example #13
0
void IPlugInstrument::ProcessMidiMsg(IMidiMsg* pMsg)
{
	// List all MIDI messages this plugin will handle.
	switch (pMsg->StatusMsg())
	{
		case IMidiMsg::kNoteOn:
		case IMidiMsg::kNoteOff:
			break;

		case IMidiMsg::kControlChange:
			switch (pMsg->ControlChangeIdx())
			{
				case IMidiMsg::kChannelVolume:
				{
					// Update the volume parameter in the UI only.
					double volume = pMsg->ControlChange(IMidiMsg::kChannelVolume);
					if (GetGUI())
						GetGUI()->SetParameterFromPlug(kVolume, volume, false);
					else
						GetParam(kVolume)->Set(volume);
					InformHostOfParamChange(kVolume, volume);
				}
				break;

				case IMidiMsg::kAllNotesOff:
					break;

				// Discard all other Control Change messages.
				default:
					SendMidiMsg(pMsg);
					return;
			}
			break;

		// Discard all other MIDI messages.
		default:
			SendMidiMsg(pMsg);
			return;
	}

	// Don't handle the MIDI message just yet (we'll do that in
	// ProcessDoubleReplacing), but instead add it to the queue.
	mMidiQueue.Add(pMsg);
}
Example #14
0
//Called by the standalone wrapper if someone clicks about
bool IPlugMultiTargets::HostRequestingAboutBox()
{
  IMutexLock lock(this);
  if(GetGUI()) {
    // get the IBitmapOverlay to show
    mAboutBox->SetValueFromPlug(1.);
    mAboutBox->Hide(false);
  }
  return true;
}
Example #15
0
void IGUIButtonBehavior::DrawButton(const CRect& rect, const float& z, CGUISpriteInstance& sprite, CGUISpriteInstance& sprite_over, CGUISpriteInstance& sprite_pressed, CGUISpriteInstance& sprite_disabled, int cell_id)
{
	if (!GetGUI())
		return;

	bool enabled;
	GUI<bool>::GetSetting(this, "enabled", enabled);

	if (!enabled)
		GetGUI()->DrawSprite(GUI<>::FallBackSprite(sprite_disabled, sprite), cell_id, z, rect);
	else if (m_MouseHovering)
	{
		if (m_Pressed)
			GetGUI()->DrawSprite(GUI<>::FallBackSprite(sprite_pressed, sprite), cell_id, z, rect);
		else
			GetGUI()->DrawSprite(GUI<>::FallBackSprite(sprite_over, sprite), cell_id, z, rect);
	}
	else
		GetGUI()->DrawSprite(sprite, cell_id, z, rect);
}
Example #16
0
void CButton::SetupText()
{
	if (!GetGUI())
		return;

	ENSURE(m_GeneratedTexts.size()==1);

	CStrW font;
	if (GUI<CStrW>::GetSetting(this, "font", font) != PSRETURN_OK || font.empty())
		// Use the default if none is specified
		// TODO Gee: (2004-08-14) Default should not be hard-coded, but be in styles!
		font = L"default";

	CGUIString caption;
	GUI<CGUIString>::GetSetting(this, "caption", caption);

	float buffer_zone=0.f;
	GUI<float>::GetSetting(this, "buffer_zone", buffer_zone);
	*m_GeneratedTexts[0] = GetGUI()->GenerateText(caption, font, m_CachedActualSize.GetWidth(), buffer_zone, this);

	CalculateTextPosition(m_CachedActualSize, m_TextPos, *m_GeneratedTexts[0]);
}
Example #17
0
void IPlugAAX::ResizeGraphics(int w, int h)
{
  IGraphics* pGraphics = GetGUI();
  
  if (pGraphics)
  {
    AAX_Point oEffectViewSize;
    oEffectViewSize.horz = (float) w;
    oEffectViewSize.vert = (float) h;
    pGraphics->GetViewContainer()->SetViewSize(oEffectViewSize);

    OnWindowResize();
  }
}
Example #18
0
AAX_Result IPlugAAX::UpdateParameterNormalizedValue(AAX_CParamID iParameterID, double iValue, AAX_EUpdateSource iSource )
{
  TRACE;
  
  AAX_Result  result = AAX_SUCCESS;
  
  AAX_IParameter* parameter = mParameterManager.GetParameterByID(iParameterID);
    
  if (parameter == 0)
    return AAX_ERROR_INVALID_PARAMETER_ID;
  
  // Store the value into the parameter.
  parameter->UpdateNormalizedValue(iValue);
  
  int paramIdx = atoi(iParameterID) - kAAXParamIdxOffset;
  
  if ((paramIdx >= 0) && (paramIdx < NParams())) 
  {
    IMutexLock lock(this);
    
    GetParam(paramIdx)->SetNormalized(iValue);
    
    if (GetGUI())
    {
      GetGUI()->SetParameterFromPlug(paramIdx, iValue, true);
    }
    
    OnParamChange(paramIdx, kAutomation);
  }
  
  // Now the control has changed
  result = mPacketDispatcher.SetDirty(iParameterID);
  
  mNumPlugInChanges++;
  
  return result;
}
Example #19
0
void Arponaut::ProcessDoubleReplacing(double** inputs, double** outputs, int nFrames)
{
    // Mutex is already locked for us.
    ENoteLength noteLength = (ENoteLength) ((int(GetParam(kNoteLength)->Value())) + 1);
    EOctaves    octaves    = (EOctaves)    ((int(GetParam(kOctaves)->Value())) + 1);
    EArpMode    arpMode    = (EArpMode)    (int(GetParam(kArpMode)->Value()));
    EInsertMode insertMode = (EInsertMode) (int(GetParam(kInsertMode)->Value()));

    if (GetGUI()) {
        //GetGUI()->SetControlFromPlug(mMeterIdx_L, peakL);
        //GetGUI()->SetControlFromPlug(mMeterIdx_R, peakR);
    }

    int pos = GetSamplePos();
    running_ = (pos != lastPos_);
    int tnum, tden;
    GetTimeSig(&tnum, &tden);

    if (keymap_.held() == 0) {
        NoteOff(); // only sent if a note is already playing
    }
    
    if (running_ && keymap_.held()) {
        sequence_->setOctaves(octaves);
        sequence_->setArpMode(arpMode);
        sequence_->setInsertMode(insertMode);

        double perBeat = GetSamplesPerBeat() / noteLength;
        // trigger?
        int ibar = static_cast<int>(double(pos) / perBeat);
        int ilastBar = static_cast<int>(double(lastPos_) / perBeat);

        if ((pos == 0 && ibar == 0) || (ibar != ilastBar)) {
            // Log("pos %d pb %f Num %d Den %d ibar %d lastbar %d\n", pos, perBeat, tnum, tden, ibar, ilastBar);
            NoteOff();
            IMidiMsg* next = sequence_->next();

            if (next && next->StatusMsg() == IMidiMsg::kNoteOn) {
                SendMidiMsg(next);
                playing_ = *next;
            }

            matrix->SetDirty(false);
        }
    }

    lastPos_ = pos;
}
Example #20
0
void IPlugStandalone::ResizeGraphics(int w, int h)
{
  #ifndef OS_IOS
  IGraphics* pGraphics = GetGUI();
  if (pGraphics)
  {
    #ifdef OS_OSX
    #define TITLEBAR_BODGE 22
    RECT r;
    GetWindowRect(gHWND, &r);
    SetWindowPos(gHWND, 0, r.left, r.bottom - pGraphics->Height() - TITLEBAR_BODGE, pGraphics->Width(), pGraphics->Height() + TITLEBAR_BODGE, 0);
    #endif
    OnWindowResize();
  }
  #endif
}
Example #21
0
bool CDropDown::MouseOver()
{
	if(!GetGUI())
		throw PSERROR_GUI_OperationNeedsGUIObject();

	if (m_Open)
	{
		CRect rect(m_CachedActualSize.left, m_CachedActualSize.top,
				   m_CachedActualSize.right, GetListRect().bottom);


		return rect.PointInside(GetMousePos());
	}
	else
		return m_CachedActualSize.PointInside(GetMousePos());
}
Example #22
0
void IPlugChunks::ProcessDoubleReplacing(double** inputs, double** outputs, int nFrames)
{
  // Mutex is already locked for us.

  double* in1 = inputs[0];
  double* in2 = inputs[1];
  double* out1 = outputs[0];
  double* out2 = outputs[1];

  int samplesPerBeat = (int) GetSamplesPerBeat();
  int samplePos = (int) GetSamplePos();

  int count = mCount;
  int prevcount = mPrevCount;

  for (int s = 0; s < nFrames; ++s, ++in1, ++in2, ++out1, ++out2)
  {
    int mod = (samplePos + s) % (samplesPerBeat * BEAT_DIV);

    count = mod / (samplesPerBeat / BEAT_DIV);

    if (count >= NUM_SLIDERS)
    {
      count = 0;
    }

    if (count != prevcount)
    {
      if (GetGUI())
      {
        mMSlider->SetHighlight(count);
      }
    }

    prevcount = count;

    *out1 = *in1 * mSteps[count] * mGain;
    *out2 = *in2 * mSteps[count] * mGain;
  }

  mCount = count;
  mPrevCount = prevcount;

}
Example #23
0
PlayState::PlayState() :
	mQuitButton(new gcn::Button())
{
	// Create a top-level container
	gcn::ContainerPtr top(new gcn::Container());
	top->SetFocusable(true);
	top->SetSize(800, 40);
	GetGUI()->SetTop(top);

	// Configure a quit-button
	mQuitButton->SetCaption("Quit");
   // mQuitButton->SetForegroundColor(gcn::Color(255,255,255,255));
	mQuitButton->AdjustSize();

	top->Add(mQuitButton, 103, 103);

	// Listen for mouse events
	top->addMouseListener(this);
}
Example #24
0
void CMiniMap::Draw()
{
	PROFILE3("render minimap");

	// The terrain isn't actually initialized until the map is loaded, which
	// happens when the game is started, so abort until then.
	if(!(GetGUI() && g_Game && g_Game->IsGameStarted()))
		return;

	CSimulation2* sim = g_Game->GetSimulation2();
	CmpPtr<ICmpRangeManager> cmpRangeManager(*sim, SYSTEM_ENTITY);
	ENSURE(cmpRangeManager);

	// Set our globals in case they hadn't been set before
	m_Camera      = g_Game->GetView()->GetCamera();
	m_Terrain     = g_Game->GetWorld()->GetTerrain();
	m_Width  = (u32)(m_CachedActualSize.right - m_CachedActualSize.left);
	m_Height = (u32)(m_CachedActualSize.bottom - m_CachedActualSize.top);
	m_MapSize = m_Terrain->GetVerticesPerSide();
	m_TextureSize = (GLsizei)round_up_to_pow2((size_t)m_MapSize);
	m_MapScale = (cmpRangeManager->GetLosCircular() ? 1.f : 1.414f);

	if(!m_TerrainTexture || g_GameRestarted)
		CreateTextures();


	// only update 2x / second
	// (note: since units only move a few pixels per second on the minimap,
	// we can get away with infrequent updates; this is slow)
	static double last_time;
	const double cur_time = timer_Time();
	if(cur_time - last_time > 0.5)
	{
		last_time = cur_time;

		if(m_TerrainDirty)
			RebuildTerrainTexture();
	}

	glMatrixMode(GL_PROJECTION);
	glPushMatrix();
	glLoadIdentity();
	glMatrixMode(GL_MODELVIEW);
	glPushMatrix();
	CMatrix3D matrix = GetDefaultGuiMatrix();
	glLoadMatrixf(&matrix._11);

	// Disable depth updates to prevent apparent z-fighting-related issues
	// with some drivers causing units to get drawn behind the texture
	glDepthMask(0);

	const float x = m_CachedActualSize.left, y = m_CachedActualSize.bottom;
	const float x2 = m_CachedActualSize.right, y2 = m_CachedActualSize.top;
	const float z = GetBufferedZ();
	const float texCoordMax = (float)(m_MapSize - 1) / (float)m_TextureSize;
	const float angle = GetAngle();

	// Draw the main textured quad
	g_Renderer.BindTexture(0, m_TerrainTexture);
	glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
	DrawTexture(texCoordMax, angle, x, y, x2, y2, z);


	// Draw territory boundaries
	CTerritoryTexture& territoryTexture = g_Game->GetView()->GetTerritoryTexture();
	territoryTexture.BindTexture(0);
	glEnable(GL_BLEND);
	glMatrixMode(GL_TEXTURE);
	glLoadMatrixf(territoryTexture.GetMinimapTextureMatrix());
	glMatrixMode(GL_MODELVIEW);

	DrawTexture(1.0f, angle, x, y, x2, y2, z);

	glMatrixMode(GL_TEXTURE);
	glLoadIdentity();
	glMatrixMode(GL_MODELVIEW);
	glDisable(GL_BLEND);


	// Draw the LOS quad in black, using alpha values from the LOS texture
	CLOSTexture& losTexture = g_Game->GetView()->GetLOSTexture();
	losTexture.BindTexture(0);
	glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE);
	glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_ARB, GL_REPLACE);
	glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_ARB, GL_PRIMARY_COLOR_ARB);
	glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB_ARB, GL_SRC_COLOR);
	glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA_ARB, GL_REPLACE);
	glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA_ARB, GL_TEXTURE);
	glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA_ARB, GL_ONE_MINUS_SRC_ALPHA);
	glEnable(GL_BLEND);
	glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
	glColor3f(0.0f, 0.0f, 0.0f);

	glMatrixMode(GL_TEXTURE);
	glLoadMatrixf(losTexture.GetMinimapTextureMatrix());
	glMatrixMode(GL_MODELVIEW);

	DrawTexture(1.0f, angle, x, y, x2, y2, z);

	glMatrixMode(GL_TEXTURE);
	glLoadIdentity();
	glMatrixMode(GL_MODELVIEW);

	glDisable(GL_BLEND);

	// Set up the matrix for drawing points and lines
	glPushMatrix();
	glTranslatef(x, y, z);
	// Rotate around the center of the map
	glTranslatef((x2-x)/2.f, (y2-y)/2.f, 0.f);
	// Scale square maps to fit in circular minimap area
	float unitScale = (cmpRangeManager->GetLosCircular() ? 1.f : m_MapScale/2.f);
	glScalef(unitScale, unitScale, 1.f);
	glRotatef(angle * 180.f/M_PI, 0.f, 0.f, 1.f);
	glTranslatef(-(x2-x)/2.f, -(y2-y)/2.f, 0.f);

	PROFILE_START("minimap units");

	// Don't enable GL_POINT_SMOOTH because it's far too slow
	// (~70msec/frame on a GF4 rendering a thousand points)
	glPointSize(3.f);

	float sx = (float)m_Width / ((m_MapSize - 1) * TERRAIN_TILE_SIZE);
	float sy = (float)m_Height / ((m_MapSize - 1) * TERRAIN_TILE_SIZE);

	CSimulation2::InterfaceList ents = sim->GetEntitiesWithInterface(IID_Minimap);

	std::vector<MinimapUnitVertex> vertexArray;
	vertexArray.reserve(ents.size());

	for (CSimulation2::InterfaceList::const_iterator it = ents.begin(); it != ents.end(); ++it)
	{
		MinimapUnitVertex v;
		ICmpMinimap* cmpMinimap = static_cast<ICmpMinimap*>(it->second);
		entity_pos_t posX, posZ;
		if (cmpMinimap->GetRenderData(v.r, v.g, v.b, posX, posZ))
		{
			ICmpRangeManager::ELosVisibility vis = cmpRangeManager->GetLosVisibility(it->first, g_Game->GetPlayerID());
			if (vis != ICmpRangeManager::VIS_HIDDEN)
			{
				v.a = 255;
				v.x = posX.ToFloat()*sx;
				v.y = -posZ.ToFloat()*sy;
				vertexArray.push_back(v);
			}
		}
	}

	if (!vertexArray.empty())
	{
		glEnableClientState(GL_VERTEX_ARRAY);
		glEnableClientState(GL_COLOR_ARRAY);
		glVertexPointer(2, GL_FLOAT, sizeof(MinimapUnitVertex), &vertexArray[0].x);
		glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(MinimapUnitVertex), &vertexArray[0].r);

		glDrawArrays(GL_POINTS, 0, (GLsizei)vertexArray.size());

		glDisableClientState(GL_COLOR_ARRAY);
		glDisableClientState(GL_VERTEX_ARRAY);
	}

	PROFILE_END("minimap units");

	DrawViewRect();

	glPopMatrix();


	glMatrixMode(GL_PROJECTION);
	glPopMatrix();
	glMatrixMode(GL_MODELVIEW);
	glPopMatrix();

	// Reset everything back to normal
	glPointSize(1.0f);
	glEnable(GL_TEXTURE_2D);
	glDepthMask(1);
}
Example #25
0
void IPlugSideChain::ProcessDoubleReplacing(double** inputs, double** outputs, int nFrames)
{
  // Mutex is already locked for us.

  bool in1ic = IsInChannelConnected(0);
  bool in2ic = IsInChannelConnected(1);
  bool in3ic = IsInChannelConnected(2);
  bool in4ic = IsInChannelConnected(3);

  printf("%i %i %i %i, ------------------------- \n", in1ic, in2ic, in3ic, in4ic);

#ifdef RTAS_API
  double* in1 = inputs[0];
  double* in2 = inputs[1];
  double* scin1 = inputs[2];

  double* out1 = outputs[0];
  double* out2 = outputs[1];

  double peakL = 0.0, peakR = 0.0, peakLS = 0.0;

  for (int s = 0; s < nFrames; ++s, ++in1, ++in2, ++scin1, ++out1, ++out2)
  {
    *out1 = *in1 * mGain;
    *out2 = *in2 * mGain;

    peakL = IPMAX(peakL, fabs(*in1));
    peakR = IPMAX(peakR, fabs(*in2));
    peakLS = IPMAX(peakLS, fabs(*scin1));
  }

  double xL = (peakL < mPrevL ? METER_DECAY : METER_ATTACK);
  double xR = (peakR < mPrevR ? METER_DECAY : METER_ATTACK);
  double xLS = (peakLS < mPrevLS ? METER_DECAY : METER_ATTACK);

  peakL = peakL * xL + mPrevL * (1.0 - xL);
  peakR = peakR * xR + mPrevR * (1.0 - xR);
  peakLS = peakLS * xLS + mPrevLS * (1.0 - xLS);

  mPrevL = peakL;
  mPrevR = peakR;
  mPrevLS = peakLS;

  if (GetGUI())
  {
    GetGUI()->SetControlFromPlug(mMeterIdx_L, peakL);
    GetGUI()->SetControlFromPlug(mMeterIdx_R, peakR);
    GetGUI()->SetControlFromPlug(mMeterIdx_LS, peakLS);
  }

#else
  double* in1 = inputs[0];
  double* in2 = inputs[1];
  double* scin1 = inputs[2];
  double* scin2 = inputs[3];

  double* out1 = outputs[0];
  double* out2 = outputs[1];

  double peakL = 0.0, peakR = 0.0, peakLS = 0.0, peakRS = 0.0;

//Stupid hack because logic connects the sidechain bus to the main bus when no sidechain is connected
//see coreaudio mailing list
#ifdef AU_API
  if (GetHost() == kHostLogic)
  {
    if(!memcmp(in1, scin1, nFrames * sizeof(double)))
    {
      memset(scin1, 0, nFrames * sizeof(double));
      memset(scin2, 0, nFrames * sizeof(double));
    }
  }
#endif

  for (int s = 0; s < nFrames; ++s, ++in1, ++in2, ++scin1, ++scin2, ++out1, ++out2)
  {
    *out1 = *in1 * mGain;
    *out2 = *in2 * mGain;

    peakL = IPMAX(peakL, fabs(*in1));
    peakR = IPMAX(peakR, fabs(*in2));
    peakLS = IPMAX(peakLS, fabs(*scin1));
    peakRS = IPMAX(peakRS, fabs(*scin2));
  }

  double xL = (peakL < mPrevL ? METER_DECAY : METER_ATTACK);
  double xR = (peakR < mPrevR ? METER_DECAY : METER_ATTACK);
  double xLS = (peakLS < mPrevLS ? METER_DECAY : METER_ATTACK);
  double xRS = (peakRS < mPrevRS ? METER_DECAY : METER_ATTACK);

  peakL = peakL * xL + mPrevL * (1.0 - xL);
  peakR = peakR * xR + mPrevR * (1.0 - xR);
  peakLS = peakLS * xLS + mPrevLS * (1.0 - xLS);
  peakRS = peakRS * xRS + mPrevRS * (1.0 - xRS);

  mPrevL = peakL;
  mPrevR = peakR;
  mPrevLS = peakLS;
  mPrevRS = peakRS;

  if (GetGUI())
  {
    GetGUI()->SetControlFromPlug(mMeterIdx_L, peakL);
    GetGUI()->SetControlFromPlug(mMeterIdx_R, peakR);
    GetGUI()->SetControlFromPlug(mMeterIdx_LS, peakLS);
    GetGUI()->SetControlFromPlug(mMeterIdx_RS, peakRS);
  }
#endif
}
Example #26
0
bool IGUIObject::IsRootObject() const
{
	return (GetGUI() != 0 && m_pParent == GetGUI()->m_BaseObject);
}
Example #27
0
bool IGUIObject::IsFocused() const
{
	return GetGUI()->m_FocusedObject == this;
}
Example #28
0
void IGUIObject::SetFocus()
{
	GetGUI()->m_FocusedObject = this;
}
Example #29
0
void CList::DrawList(const int& selected, const CStr& _sprite, const CStr& _sprite_selected, const CStr& _textcolor)
{
	float bz = GetBufferedZ();

	// First call draw on ScrollBarOwner
	bool scrollbar;
	GUI<bool>::GetSetting(this, "scrollbar", scrollbar);

	if (scrollbar)
		IGUIScrollBarOwner::Draw();

	if (GetGUI())
	{
		CRect rect = GetListRect();

		CGUISpriteInstance* sprite = NULL;
		CGUISpriteInstance* sprite_selectarea = NULL;
		int cell_id;
		GUI<CGUISpriteInstance>::GetSettingPointer(this, _sprite, sprite);
		GUI<CGUISpriteInstance>::GetSettingPointer(this, _sprite_selected, sprite_selectarea);
		GUI<int>::GetSetting(this, "cell_id", cell_id);

		CGUIList* pList;
		GUI<CGUIList>::GetSettingPointer(this, "list", pList);

		GetGUI()->DrawSprite(*sprite, cell_id, bz, rect);

		float scroll = 0.f;
		if (scrollbar)
			scroll = GetScrollBar(0).GetPos();

		if (selected != -1)
		{
			ENSURE(selected >= 0 && selected+1 < (int)m_ItemsYPositions.size());

			// Get rectangle of selection:
			CRect rect_sel(rect.left, rect.top + m_ItemsYPositions[selected] - scroll,
					       rect.right, rect.top + m_ItemsYPositions[selected+1] - scroll);

			if (rect_sel.top <= rect.bottom &&
				rect_sel.bottom >= rect.top)
			{
				if (rect_sel.bottom > rect.bottom)
					rect_sel.bottom = rect.bottom;
				if (rect_sel.top < rect.top)
					rect_sel.top = rect.top;

				if (scrollbar)
				{
					// Remove any overlapping area of the scrollbar.
					if (rect_sel.right > GetScrollBar(0).GetOuterRect().left &&
						rect_sel.right <= GetScrollBar(0).GetOuterRect().right)
						rect_sel.right = GetScrollBar(0).GetOuterRect().left;

					if (rect_sel.left >= GetScrollBar(0).GetOuterRect().left &&
						rect_sel.left < GetScrollBar(0).GetOuterRect().right)
						rect_sel.left = GetScrollBar(0).GetOuterRect().right;
				}

				GetGUI()->DrawSprite(*sprite_selectarea, cell_id, bz+0.05f, rect_sel);
			}
		}

		CColor color;
		GUI<CColor>::GetSetting(this, _textcolor, color);

		for (size_t i = 0; i < pList->m_Items.size(); ++i)
		{
			if (m_ItemsYPositions[i+1] - scroll < 0 ||
				m_ItemsYPositions[i] - scroll > rect.GetHeight())
				continue;

			// Clipping area (we'll have to substract the scrollbar)
			CRect cliparea = GetListRect();

			if (scrollbar)
			{
				if (cliparea.right > GetScrollBar(0).GetOuterRect().left &&
					cliparea.right <= GetScrollBar(0).GetOuterRect().right)
					cliparea.right = GetScrollBar(0).GetOuterRect().left;

				if (cliparea.left >= GetScrollBar(0).GetOuterRect().left &&
					cliparea.left < GetScrollBar(0).GetOuterRect().right)
					cliparea.left = GetScrollBar(0).GetOuterRect().right;
			}

			DrawText(i, color, rect.TopLeft() - CPos(0.f, scroll - m_ItemsYPositions[i]), bz+0.1f, cliparea);
		}
	}
}
Example #30
0
void CList::SetupText()
{
	if (!GetGUI())
		return;

	m_Modified = true;
	CGUIList* pList;
	GUI<CGUIList>::GetSettingPointer(this, "list", pList);

	//ENSURE(m_GeneratedTexts.size()>=1);

	m_ItemsYPositions.resize(pList->m_Items.size()+1);

	// Delete all generated texts. Some could probably be saved,
	//  but this is easier, and this function will never be called
	//  continuously, or even often, so it'll probably be okay.
	for (SGUIText* const& t : m_GeneratedTexts)
		delete t;
	m_GeneratedTexts.clear();

	CStrW font;
	if (GUI<CStrW>::GetSetting(this, "font", font) != PSRETURN_OK || font.empty())
		// Use the default if none is specified
		// TODO Gee: (2004-08-14) Don't define standard like this. Do it with the default style.
		font = L"default";

	bool scrollbar;
	GUI<bool>::GetSetting(this, "scrollbar", scrollbar);

	float width = GetListRect().GetWidth();
	// remove scrollbar if applicable
	if (scrollbar && GetScrollBar(0).GetStyle())
		width -= GetScrollBar(0).GetStyle()->m_Width;

	float buffer_zone = 0.f;
	GUI<float>::GetSetting(this, "buffer_zone", buffer_zone);

	// Generate texts
	float buffered_y = 0.f;

	for (size_t i = 0; i < pList->m_Items.size(); ++i)
	{
		// Create a new SGUIText. Later on, input it using AddText()
		SGUIText* text = new SGUIText();

		*text = GetGUI()->GenerateText(pList->m_Items[i], font, width, buffer_zone, this);

		m_ItemsYPositions[i] = buffered_y;
		buffered_y += text->m_Size.cy;

		AddText(text);
	}

	m_ItemsYPositions[pList->m_Items.size()] = buffered_y;

	// Setup scrollbar
	if (scrollbar)
	{
		GetScrollBar(0).SetScrollRange(m_ItemsYPositions.back());
		GetScrollBar(0).SetScrollSpace(GetListRect().GetHeight());

		CRect rect = GetListRect();
		GetScrollBar(0).SetX(rect.right);
		GetScrollBar(0).SetY(rect.top);
		GetScrollBar(0).SetZ(GetBufferedZ());
		GetScrollBar(0).SetLength(rect.bottom - rect.top);
	}
}