void AppOnJoypad(JNIEnv* env, jobject jobj, jfloat xL, jfloat yL, jfloat xR, jfloat yR) { LogMsg("Got %.2f, %.2f and %.2f, %.2f", xL, yL, xR, yR); #ifdef RT_MOGA_ENABLED //for Seth's GamepadManagerMoga implementation, so it can be abstracted like any other gamepad VariantList vList((uint32)MESSAGE_TYPE_GUI_JOYPAD, xL, yL, xR, yR); BaseApp::GetBaseApp()->m_sig_joypad_events(&vList); #else //legacy, for Jake's stuff VariantList vList( xL, yL, xR, yR); MessageManager::GetMessageManager()->SendGUI(MESSAGE_TYPE_GUI_JOYPAD, vList); #endif }
void TouchDragComponent::SetPosition(CL_Vec2f vInputPos) { //if (vPos == m_lastPos) return; //LogMsg("Setting position of %s", PrintVector2(vInputPos).c_str()); CL_Vec2f vPos = vInputPos-m_lastPos; m_lastPos = vInputPos; if (*m_pSwapXAndY != 0) { swap(vPos.x, vPos.y); } if (*m_pReverseX != 0) { vPos.x *= -1; } if (*m_pReverseY != 0) { vPos.y *= -1; } VariantList vList(this, vPos); m_pOnTouchDragUpdate->m_sig_function(&vList); }
//testing accelerometer readings. To enable the test, search below for "ACCELTEST" //Note: You'll need to look at the debug log to see the output. (For android, run PhoneLog.bat from RTBareBones/android) void App::OnAccel(VariantList *pVList) { if ( int(pVList->m_variant[0].GetFloat()) != MESSAGE_TYPE_GUI_ACCELEROMETER) return; CL_Vec3f v = pVList->m_variant[1].GetVector3(); LogMsg("Accel: %s", PrintVector3(v).c_str()); v.x = v.x * kFilteringFactor + v.x * (1.0f - kFilteringFactor); v.y = v.y * kFilteringFactor + v.y * (1.0f - kFilteringFactor); v.z = v.z * kFilteringFactor + v.z * (1.0f - kFilteringFactor); // Compute values for the three axes of the acceleromater float x = v.x - v.x; float y = v.y - v.x; float z = v.z - v.x; //Compute the intensity of the current acceleration if (sqrt(x * x + y * y + z * z) > 2.0f) { Entity *pEnt = GetEntityRoot()->GetEntityByName("jumble"); if (pEnt) { //GetAudioManager()->Play("audio/click.wav"); VariantList vList(CL_Vec2f(), pEnt); pEnt->GetFunction("OnButtonSelected")->sig_function(&vList); } LogMsg("Shake!"); } }
void TouchDragComponent::EndDrag(int fingerID, CL_Vec2f pt) { if (m_activeFingerID == fingerID) { VariantList vList(pt, GetParent(), uint32(fingerID)); GetParent()->GetFunction("OnOverEnd")->m_sig_function(&vList); m_activeFingerID = -1; } }
void EntityComponent::OnRemove() { FunctionObject *pFunc = GetShared()->GetFunctionIfExists("OnDelete"); if (pFunc) { //looks like someone wanted notification VariantList vList(this); pFunc->m_sig_function(&vList); } }
void AppOnJoypadConnection(JNIEnv* env, jobject jobj, jint connect) { // LogMsg("Received connect value %d", connect); #ifdef RT_MOGA_ENABLED //for Seth's GamepadManagerMoga implementation, so it can be abstracted like any other gamepad VariantList vList((uint32)MESSAGE_TYPE_GUI_JOYPAD_CONNECT, (uint32)connect); BaseApp::GetBaseApp()->m_sig_joypad_events(&vList); #else { MessageManager::GetMessageManager()->SendGUI(MESSAGE_TYPE_GUI_JOYPAD_CONNECT, Variant(connect, 0.0f, 0.0f)); } #endif }
// JAKE ADDED - MachineWorks needs this, so please leave. void AppOnJoypadButtons(JNIEnv* env, jobject jobj, jint key, jint value) { #ifdef RT_MOGA_ENABLED //for Seth's GamepadManagerMoga implementation, so it can be abstracted like any other gamepad //LogMsg("Received key %d, value %d", key, value); VariantList vList((uint32)MESSAGE_TYPE_GUI_JOYPAD_BUTTONS, (uint32) key, (uint32)value); BaseApp::GetBaseApp()->m_sig_joypad_events(&vList); #else //LogMsg("Jakes: Received key %d, value %d", key, value); MessageManager::GetMessageManager()->SendGUI(MESSAGE_TYPE_GUI_JOYPAD_BUTTONS, Variant(key, value, 0.0f)); #endif }
// **************************************************************************** WindowProperties::~WindowProperties(void) { // Delete the menu properties (if available) if (mWindowMenuProperties) delete mWindowMenuProperties; // Delete all objects from the mHToolbarPropertiesList QVectorIterator<ToolbarProperties*> hList(mHToolbarPropertiesList); ToolbarProperties* toolbarProperties = 0; hList.toFront(); while (hList.hasNext()) { toolbarProperties = hList.next(); if (toolbarProperties) delete toolbarProperties; } mHToolbarPropertiesList.clear(); // Delete all objects from the mVToolbarPropertiesList QVectorIterator<ToolbarProperties*> vList(mVToolbarPropertiesList); vList.toFront(); while (vList.hasNext()) { toolbarProperties = vList.next(); if (toolbarProperties) delete toolbarProperties; } mVToolbarPropertiesList.clear(); // Delete all objects from the mTabPropertiesList QVectorIterator<TabProperties*> tabList(mTabPropertiesList); TabProperties* tabProperties = 0; tabList.toFront(); while (tabList.hasNext()) { tabProperties = tabList.next(); if (tabProperties) delete tabProperties; } mTabPropertiesList.clear(); }
void TouchDragComponent::OnInput( VariantList *pVList ) { //0 = message type, 1 = parent coordinate offset CL_Vec2f pt = pVList->Get(1).GetVector2(); uint32 fingerID = 0; if (pVList->Get(2).GetType() == Variant::TYPE_UINT32) { fingerID = pVList->Get(2).GetUINT32(); } //LogMsg("Detected finger %d at %s", fingerID, PrintVector2(pt).c_str()); switch (eMessageType( int(pVList->Get(0).GetFloat()))) { case MESSAGE_TYPE_GUI_CLICK_START: //first, determine if the click is on our area { if (*m_pDisabled != 0) return; CL_Rectf r(*m_pPos2d, CL_Sizef(m_pSize2d->x, m_pSize2d->y)); ApplyPadding(&r, *m_pTouchPadding); if (r.contains(pt)) { if (m_activeFingerID != -1) { //LogMsg("Ignoring new finger.."); return; } TouchTrackInfo *pTouch = BaseApp::GetBaseApp()->GetTouch(pVList->Get(2).GetUINT32()); if (pTouch->WasHandled()) return; pTouch->SetWasHandled(true); VariantList vList(pt, GetParent(), uint32(fingerID)); GetParent()->GetFunction("OnOverStart")->m_sig_function(&vList); m_lastPos = pt; m_activeFingerID = fingerID; } } break; case MESSAGE_TYPE_GUI_CLICK_END: EndDrag(fingerID, pt); break; case MESSAGE_TYPE_GUI_CLICK_MOVE: if (*m_pDisabled != 0) { EndDrag(fingerID, pt); return; } if (m_activeFingerID == fingerID) { SetPosition(pt); } break; default: ; } }
void BaseApp::Draw() { #ifdef _DEBUG //LogMsg("**********FRAME START"); #endif VariantList vList(Variant(0,0)); m_sig_render(&vList); if (GetFPSVisible()) { char stTemp[256]; sprintf(stTemp, "fps: %d - M: %.2f, T: %.2f A: %.2f F: %.2f", m_gameTimer.GetFPS(), (float(m_memUsed)/1024)/1024, (float(m_texMemUsed)/1024)/1024, float(GetAudioManager()->GetMemoryUsed()/1024)/ 1024, float(GetFreeMemory()/1024)/ 1024); #ifdef _IRR_STATIC_LIB_ int prims = 0; if (GetIrrlichtManager()->GetDriver()) { prims = GetIrrlichtManager()->GetDriver()->getPrimitiveCountDrawn(); } char stExtra[256]; sprintf(stExtra, " Prims: %d", prims); strcat(stTemp, stExtra); #endif #ifdef PLATFORM_FLASH char stExtra[256]; sprintf(stExtra, " Flash: %.2f", float(GetNativeMemoryUsed())/1024/1024); strcat(stTemp, stExtra); #endif if (GetFont(FONT_SMALL)->IsLoaded()) { GetFont(FONT_SMALL)->DrawScaled(3,3, stTemp, 0.7f); } } //draw the console messages? if (GetConsoleVisible()) { DrawConsole(); } switch (GetLastError()) { case ERROR_MEM: GetFont(FONT_SMALL)->DrawScaled(2,14, "LOW MEM!", 0.7f); break; case ERROR_SPACE: GetFont(FONT_SMALL)->DrawScaled(2,14, "LOW STORAGE SPACE!", 0.7f); break; case ERROR_NONE: break; } SetupOrtho(); g_globalBatcher.Flush(); }
void AdManager::OnMessage( Message &m ) { list<AdProvider*>::iterator itor = m_providers.begin(); for (;itor != m_providers.end(); itor++) { if ( (*itor)->OnMessage(m)) { //it signalled that it handled it and we shouldn't continue processing return; } } if (m_returnState == RETURN_STATE_WAITING) { switch (m.GetType()) { case MESSAGE_TYPE_TAPJOY_SPEND_TAP_POINTS_RETURN: m_returnState = RETURN_STATE_SUCCESS; ClearError(); break; case MESSAGE_TYPE_TAPJOY_SPEND_TAP_POINTS_RETURN_ERROR: m_returnState = RETURN_STATE_ERROR; m_lastError = m.GetStringParm(); break; default: ; } } switch (m.GetType()) { case MESSAGE_TYPE_TAPJOY_EARNED_TAP_POINTS: { #ifdef _DEBUG LogMsg("We just got %d tappoints!", (int)m.GetParm1()); #endif VariantList vList((int32)m.GetParm1()); m_sig_tappoints_awarded(&vList); //called when awarded tap points } break; case MESSAGE_TYPE_TAPJOY_TAP_POINTS_RETURN: m_tapPoints = (int32)m.GetParm1(); m_tapPointVariant.Set(m_tapPoints); m_tapCurrency = m.GetStringParm(); #ifdef _DEBUG LogMsg("Tap points set to %d %s", m_tapPoints, m_tapCurrency.c_str()); #endif break; case MESSAGE_TYPE_TAPJOY_MOVIE_AD_READY: if (m.GetParm1() == 1) { LogMsg("Video ad is ready!"); } else { LogMsg("Video ad failed %d - %s", m.GetParm2(), m.GetStringParm().c_str()); } break; case MESSAGE_TYPE_TAPJOY_FEATURED_APP_READY: if (m.GetParm1() == 1) { //LogMsg("Featured app is ready"); m_bTapjoyFeaturedAppReady = true; if (m_bShowTapjoyFeaturedAppASAP) { //LogMsg("Showing featured now"); SetTapjoyFeatureAppVisible(true); } } else { m_errorCount++; //error LogMsg("Error getting featured app: %s", m.GetStringParm().c_str()); if (m.GetStringParm().find("exceeded display") != string::npos) { //LogMsg("Displayed all front page ads we can get, not showing any more."); SetTapjoyFeatureAppVisible(false); } else { m_bSendTapjoyFeaturedAppRequestASAP = true; m_bTapjoyFeaturedAppReady = false; } } break; case MESSAGE_TYPE_TAPJOY_AD_READY: if (m.GetParm1() == 1) { #ifdef _DEBUG LogMsg("Tapjoy ad is ready"); #endif m_bTapjoyAdReady = true; if (m_bShowTapjoyAdASAP) { SetTapjoyAdVisible(true); } } else { //LogMsg("trying Tapjoy get ad, it had an error"); m_bSendTapjoyAdRequestASAP = true; m_bTapjoyAdReady = false; m_errorCount++; } break; default: ; } }
TInt RomFileStructure::ProcessDirectory(TRomNode* aDir) { TRACE(TSCRATCH, Print(EAlways, "ProcessDirectory (%08x) %s\n",aDir,aDir->iName)); TRACE(TDIR,Print(EAlways,"ProcessDirectory %s\nInitial:\n",aDir->iName)); TRACE(TDIR,DebugPrint()); TInt dirs=0; TInt files=0; aDir->CountDirectory(files,dirs); TInt maxSize=files+dirs*TVariantList::NumVariants; TRACE(TDIR,Print(EAlways,"files=%d dirs=%d maxSize=%d\n",files,dirs,maxSize)); RomFileStructure* pS=New(maxSize); if (!pS) return KErrNoMemory; TInt r=aDir->ProcessDirectory(pS); TRACE(TDIR,Print(EAlways,"FileList:\n")); TRACE(TDIR,pS->DebugPrint()); Directory* dir[TVariantList::EMaxVariants]; TInt v; for(v=0; v<TVariantList::NumVariants; v++) { TVariantList vList(v); Directory *pD=Directory::New(files+dirs,vList); if (!pD) return KErrNoMemory; dir[v]=pD; r=pD->Compile(*pS); if (r!=KErrNone) return r; TRACE(TDIR,Print(EAlways,"Variant %d Directory:\n",v)); TRACE(TDIR,pD->DebugPrint()); } pS->Close(); Directory *pX=Directory::New(TVariantList::NumVariants,TVariantList()); if (!pX) return KErrNoMemory; for(v=0; v<TVariantList::NumVariants; v++) { if (dir[v]->Empty()) r=KErrAlreadyExists; else r=pX->Merge(*dir[v]); if (r==KErrAlreadyExists) { dir[v]->Close(); dir[v]=NULL; } else if (r!=KErrNone) return r; } TRACE(TDIR,Print(EAlways,"Final Directories:\n",v)); TRACE(TDIR,pX->DebugPrint()); TInt count=pX->Count(); TInt i; for(i=0; i<count; i++) { Directory* pD=(Directory*)&(*pX)[i]; DirEntry* pE=DirEntry::New(aDir,pD); if (!pE) return KErrNoMemory; r=Add(*pE); // accumulate into the caller if (r==KErrOverflow) return r; } pX->Close(); return KErrNone; }
void AddKeyBinding(EntityComponent *pComp, string name, uint32 inputcode, uint32 outputcode, bool bAlsoSendAsNormalRawKey) { VariantList vList(name, inputcode, outputcode, uint32(bAlsoSendAsNormalRawKey!=0)); pComp->GetFunction("AddKeyBinding")->sig_function(&vList); }