XSDL: fixed help message

This commit is contained in:
Sergii Pylypenko
2019-10-08 18:39:36 +03:00
parent 1e71441946
commit a967016781
8 changed files with 90 additions and 34 deletions

View File

@@ -275,7 +275,7 @@ MultiABI='arm64-v8a'
# Optional shared libraries to compile - removing some of them will save space
# MP3 patents are expired, but libmad license is GPL, not LGPL
# Available libraries: mad (GPL-ed!) sdl_mixer sdl_image sdl_ttf sdl_net sdl_blitpool sdl_gfx sdl_sound intl xml2 lua jpeg png ogg flac tremor vorbis freetype xerces curl theora fluidsynth lzma lzo2 mikmod openal timidity zzip bzip2 yaml-cpp python boost_date_time boost_filesystem boost_iostreams boost_program_options boost_regex boost_signals boost_system boost_thread glu avcodec avdevice avfilter avformat avresample avutil swscale swresample bzip2
CompiledLibraries="jpeg png freetype sdl_ttf crypto"
CompiledLibraries="freetype sdl_ttf crypto sdl_savepng jpeg png"
# Application uses custom build script AndroidBuild.sh instead of Android.mk (y) or (n)
CustomBuildScript=y

View File

@@ -70,7 +70,7 @@ xkb/.libs/libxkbstubs.a \
composite/.libs/libcomposite.a \
os/.libs/libos.a \
-L$CURDIR/../../../libs/'"$1"' \
-lpixman-1 -lXfont2 -lXau -lxshmfence -lXdmcp -lfontenc -lfreetype \
-lpixman-1 -lXfont2 -lXau -lxshmfence -lXdmcp -lfontenc -lfreetype -lsdl_savepng -lpng \
-llog -lsdl-1.2 -lsdl_native_helpers -lGLESv1_CM -landroid-shmem -l:libcrypto.so.sdl.1.so -lz -lm -ldl' \
|| exit 1

View File

@@ -15,6 +15,7 @@
#include <SDL/SDL_ttf.h>
#include <SDL/SDL_screenkeyboard.h>
#include <SDL/SDL_android.h>
#include <savepng.h>
#include <android/log.h>
#include "gfx.h"
@@ -767,13 +768,13 @@ void XSDL_generateBackground(const char * port, int showHelp, int resolutionW, i
{
surf = SDL_CreateRGBSurface(SDL_SWSURFACE, 16, 16, 24, 0x0000ff, 0x00ff00, 0xff0000, 0);
SDL_FillRect(surf, NULL, 0x00002f);
SDL_SaveBMP(surf, "background.bmp");
SDL_SavePNG(surf, "background.png");
SDL_FreeSurface(surf);
return;
}
surf = SDL_CreateRGBSurface(SDL_SWSURFACE, resolutionW, resolutionH, 24, 0x0000ff, 0x00ff00, 0xff0000, 0);
SDL_FillRect(surf, NULL, 0x00002f);
SDL_FillRect(surf, NULL, 0x7f0000);
renderStringScaled("Launch these commands on your Linux PC:", 12 * resolutionH / VID_Y, resolutionW/2, y, 255, 255, 255, surf);
y += resolutionH * 30 / VID_Y;
@@ -810,7 +811,7 @@ void XSDL_generateBackground(const char * port, int showHelp, int resolutionW, i
sprintf (msg, "export PULSE_SERVER=tcp:%s:4712", saddr);
renderStringScaled(msg, 12 * resolutionH / VID_Y, resolutionW/2, y, 255, 255, 255, surf);
y += resolutionH * 15 / VID_Y;
sprintf (msg, "gnome-session & gimp");
sprintf (msg, "x-window-manager & gimp");
renderStringScaled(msg, 12 * resolutionH / VID_Y, resolutionW/2, y, 255, 255, 255, surf);
y += resolutionH * 20 / VID_Y;
}
@@ -833,7 +834,7 @@ void XSDL_generateBackground(const char * port, int showHelp, int resolutionW, i
sprintf (msg, "export DISPLAY=:0 PULSE_SERVER=tcp:127.0.0.1:4712");
renderStringScaled(msg, 12 * resolutionH / VID_Y, resolutionW/2, y, 255, 255, 255, surf);
SDL_SaveBMP(surf, "background.bmp");
SDL_SavePNG(surf, "background.png");
SDL_FreeSurface(surf);
}
@@ -928,11 +929,14 @@ void renderString(const char *c, int x, int y)
void renderStringScaled(const char *c, int size, int x, int y, int r, int g, int b, SDL_Surface * surf)
{
char fontpath[PATH_MAX];
if (!c || !c[0])
return;
SDL_Color fColor = {r, g, b};
SDL_Rect fontRect = {0, 0, 0, 0};
TTF_Font* font = TTF_OpenFont("DroidSansMono.ttf", size);
strcpy( fontpath, getenv("UNSECURE_STORAGE_DIR") );
strcat( fontpath, "/DroidSansMono.ttf" );
TTF_Font* font = TTF_OpenFont(fontpath, size);
SDL_Surface* fontSurface = TTF_RenderUTF8_Solid(font, c, fColor);
TTF_CloseFont(font);
fontRect.w = fontSurface->w;

View File

@@ -34,7 +34,11 @@ int main( int argc, char* argv[] )
port,
"-nolock",
"-noreset",
"-pn",
"-nopn",
"-listen",
"inet",
"-listen",
"inet6",
"-nolisten",
"unix",
"-fp",
@@ -42,7 +46,7 @@ int main( int argc, char* argv[] )
"-screen",
screenres,
};
int argnum = 11;
int argnum = 15;
char * envp[] = { NULL };
int printHelp = 1;
int screenResOverride = 0;
@@ -123,14 +127,15 @@ int main( int argc, char* argv[] )
sprintf( screenres, "%d/%dx%d/%dx%d", resolutionW, displayW, resolutionH, displayH, SDL_GetVideoInfo()->vfmt->BitsPerPixel );
}
XSDL_generateBackground( port, printHelp, 800, 600 );
XSDL_generateBackground( port, printHelp, 600 * resolutionW / resolutionH, 600 );
XSDL_deinitSDL();
if( printHelp )
{
sprintf( clientcmd, "%s/usr/bin/xhost + ; %s/usr/bin/xloadimage -onroot -fullscreen %s/background.bmp",
sprintf( clientcmd, "%s/usr/bin/xhost + ; %s/usr/bin/xloadimage -onroot -fullscreen %s/background.png",
getenv("SECURE_STORAGE_DIR"), getenv("SECURE_STORAGE_DIR"), getenv("UNSECURE_STORAGE_DIR") );
args[argnum] = "-exec";
args[argnum+1] = clientcmd;
argnum += 2;