Example #1
0
// Main entry point for the application
int main()
{
	int i = 0;
	bool hidden = false;
	bool adsAvailable = false;
	bool noView = false;

	if(AdmobAdsAvailable()){
		InitAds("a14bd815ee70598");
		adsAvailable = true;
	}

		
    // Wait for a quit request from the host OS
    while (!s3eDeviceCheckQuitRequest())
    {
        

		// Fill background blue
        s3eSurfaceClear(0, 0, 255);

        // Print a line of debug text to the screen at top left (0,0)
        // Starting the text with the ` (backtick) char followed by 'x' and a hex value
        // determines the colour of the text.
        s3eDebugPrint(120, 150, "`xffffffHello, World!", 0);

		if (noView){
			s3eDebugPrint(120, 190, "`xff1111No view", 0);
		}else{
			s3eDebugPrint(120, 190, "`x11ff11Ok", 0);
		}

        // Flip the surface buffer to screen
        s3eSurfaceShow();

        // Sleep for 0ms to allow the OS to process events etc.
        s3eDeviceYield(1);

		if(adsAvailable){
			i++;

			if(i>15000){
				i = 0;
				if (hidden) {
					noView = ShowAds() != 0;
				} else {
					noView = HideAds() != 0;
				}

				hidden = !hidden;
			}
		}

		s3eKeyboardUpdate();
		if(s3eKeyboardGetState(s3eKeyBack) & S3E_KEY_STATE_DOWN){
			break;
		}
    }
    return 0;
}
// Rotate the layout on rotation
static int HelloWorldRotationCallBack(void* systemData, void* userData)
{
	s3eSurfaceClear(0, 0, 255);
    const int width  = s3eSurfaceGetInt(S3E_SURFACE_WIDTH);
    const int height = s3eSurfaceGetInt(S3E_SURFACE_HEIGHT);
	return 0;
}
// Main entry point for the application
int main()
{
	message = "`xffffff";

	if (s3ePushWooshNotificationsAvailable())
	{
		s3ePushWooshRegister(S3E_PUSHWOOSH_REGISTRATION_SUCCEEDED, (s3eCallback)&OnPushRegistered, 0);
		s3ePushWooshRegister(S3E_PUSHWOOSH_MESSAGE_RECEIVED, (s3eCallback)&OnPushReceived, 0);
		s3ePushWooshRegister(S3E_PUSHWOOSH_REGISTRATION_ERROR, (s3eCallback)&OnPushRegisterError, 0);

		//s3ePushWooshNotificationRegister();
		const char* cstrApp = PW_APPID.c_str();
		s3ePushWooshNotificationRegisterWithPWAppID(cstrApp);
		s3ePushWooshStartLocationTracking();
		
		s3ePushWooshNotificationSetBadgeNumber(6);
				
		//Sample code for using local notifications
		//Currently this is available for Android only. You can use default Marmalade extension for iOS local notifications at this time.
		//s3ePushWooshClearLocalNotifications();
		
		//30 seconds for local notification to fire
		//s3ePushWooshScheduleLocalNotification("Your pumpkins are ready!", 30, 0);

		// postEvent example
		//s3ePushWooshSetUserId("${userId}");
		//s3ePushWooshPostEvent("testEvent", "{ \"attribute\" : \"value\" }");
	}

	// Wait for a quit request from the host OS
	while (!s3eDeviceCheckQuitRequest())
	{
		// Fill background blue
		s3eSurfaceClear(0, 0, 255);

		// Print a line of debug text to the screen at top left (0,0)
		// Starting the text with the ` (backtick) char followed by 'x' and a hex value
		// determines the colour of the text.
		s3eDebugPrint(120, 150, message.c_str(), 0);
		// else
		// 	s3eDebugPrint(120, 150, "`xffffffNot available :(", 0);

		// Flip the surface buffer to screen
		s3eSurfaceShow();

		// Sleep for 0ms to allow the OS to process events etc.
		s3eDeviceYield(0);
	}
	return 0;
}
void HelloWorldInit()
{
	// Fill background blue
        s3eSurfaceClear(0, 0, 255);
		int scale;
		if (s3eSurfaceGetInt(S3E_SURFACE_WIDTH) < 320 || s3eSurfaceGetInt(S3E_SURFACE_HEIGHT) < 320)
        scale = 1;
		else if (s3eSurfaceGetInt(S3E_SURFACE_WIDTH) < 480 || s3eSurfaceGetInt(S3E_SURFACE_HEIGHT) < 480)
        scale = 2;
		else
        scale = 3;
		s3eDebugSetInt(S3E_DEBUG_FONT_SCALE, scale);
		s3eSurfaceRegister(S3E_SURFACE_SCREENSIZE, HelloWorldRotationCallBack, NULL);
}
bool ExamplesMainUpdate() {
    s3eKeyboardUpdate();
    s3ePointerUpdate();

    if (!ExampleUpdate())
    {
        s3eDebugTracePrintf("ExampleUpdate returned false, exiting..");
        return false;
    }

    if (g_ClearScreen)
        s3eSurfaceClear(0xff,0xff,0xff);

    ExampleRender();
    ButtonsRender();
    SoftkeysRender();

    if (g_DrawCursor)
        CursorRender();

    s3eSurfaceShow();
    s3eDeviceYield(FRAMETIME);
    return true;
}
void createButton(char* p_btnName)
{
	// Draw button area
	int fontWidth = s3eDebugGetInt(S3E_DEBUG_FONT_WIDTH);
	int x,y,width;
	if(p_btnName != NULL && strlen(p_btnName) > 1)
		width = strlen(p_btnName)*fontWidth+10;
	int height = 40;
	//x = IwGxGetScreenWidth() - width;
	x = s3eSurfaceGetInt(S3E_SURFACE_WIDTH) - width;
	y = 2;
	 if (!(s3ePointerGetState(S3E_POINTER_BUTTON_SELECT) & S3E_POINTER_STATE_UP))
    {
        int pointerx = s3ePointerGetX();
        int pointery = s3ePointerGetY();
		if (pointerx >=x && pointerx <= x+width && pointery >=y && pointery <= y+height)
        {
            if (s3ePointerGetState(S3E_POINTER_BUTTON_SELECT) & S3E_POINTER_STATE_DOWN)
            {
                keyPressedState = S3E_KEY_STATE_DOWN;
            }
            if (s3ePointerGetState(S3E_POINTER_BUTTON_SELECT) & S3E_POINTER_STATE_PRESSED)
            {
                keyPressedState = S3E_KEY_STATE_PRESSED;
            }
			if (s3ePointerGetState(S3E_POINTER_BUTTON_SELECT) & S3E_POINTER_STATE_RELEASED)
            {
                keyPressedState = S3E_KEY_STATE_RELEASED;
				s3eDebugTraceLine("-------------Example Update Key Released-------------------");
            }
        }
    }

	if (s3ePointerGetState(S3E_POINTER_BUTTON_SELECT) & S3E_POINTER_STATE_RELEASED)
	{
		char color[64] = "`xe0ff00"; 
		char* dispText = strcat(color,p_btnName);
		s3eDebugPrint(x+5, 20,  dispText, 0);
	}

	 if (s3ePointerGetInt(S3E_POINTER_AVAILABLE))
    {
        if (keyPressedState == S3E_KEY_STATE_DOWN)
		{
			char color[64] = "`xe0ff00"; 
			char* dispText = strcat(color,p_btnName);
			s3eDebugPrint(x+5, 20,  dispText, 0);
		}
		else if(keyPressedState == S3E_KEY_STATE_PRESSED)
		{
			DrawButtonRect(x, y, width, height,97,97,249);
			char color[64] = "`xe0ff00"; 
			char* dispText = strcat(color,p_btnName);
			s3eDebugPrint(x+5, 20,  dispText, 0);
		}
		else if(keyPressedState == S3E_KEY_STATE_RELEASED)
		{
			s3eSurfaceClear(0,0,0);
			char color[64] = "`xe0ff00"; 
			char* dispText = strcat(color,p_btnName);
			s3eDebugPrint(x+5, 20,  dispText, 0);
		}
		else
		{
			char color[64] = "`xD8F809";
			char* dispText = strcat(color,p_btnName);
			s3eDebugPrint(x+5, 20,  dispText, 0);
		}
    }
}