Изменён формат задания цвета в конфигах

This commit is contained in:
Victor 2015-06-17 20:01:16 +03:00
parent d93236e378
commit 91e1aceabe
2 changed files with 16 additions and 7 deletions

View File

@ -20,7 +20,7 @@ rp.menu_item1.text = "Начать"
rp.menu_item1.x = 960 rp.menu_item1.x = 960
rp.menu_item1.y = 560 rp.menu_item1.y = 560
rp.menu_item1.font = 25 rp.menu_item1.font = 25
rp.menu_item1.color = "FFFFFFFF" rp.menu_item1.color = "#FFFFFFFF"
rp.menu_item1.action = "meet_you_there.rpy" rp.menu_item1.action = "meet_you_there.rpy"
rp.menu_item2.text = "Загрузить" rp.menu_item2.text = "Загрузить"
@ -42,4 +42,4 @@ rp.menu_item4.text = "v" + version
rp.menu_item4.x = 60 rp.menu_item4.x = 60
rp.menu_item4.y = 1000 rp.menu_item4.y = 1000
rp.menu_item4.font = 16 rp.menu_item4.font = 16
rp.menu_item4.color = "7AFFFFFF" # прозрачность 7A rp.menu_item4.color = "#7AFFFFFF" # прозрачность 7A

View File

@ -8,6 +8,7 @@ import android.app.Activity;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.content.Intent; import android.content.Intent;
import android.content.pm.PackageManager.NameNotFoundException; import android.content.pm.PackageManager.NameNotFoundException;
import android.graphics.Color;
import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.BitmapDrawable;
import android.os.Bundle; import android.os.Bundle;
import android.util.DisplayMetrics; import android.util.DisplayMetrics;
@ -67,8 +68,6 @@ public final class MainActivity extends Activity {
} }
config.addValue("load", LOAD); config.addValue("load", LOAD);
config.addValue("exit", EXIT); config.addValue("exit", EXIT);
config.addValue("white", "FFFFFFFF");
config.addValue("black", "FF000000");
config.parse(); config.parse();
// Настройка пути к ресурсам // Настройка пути к ресурсам
@ -250,9 +249,19 @@ public final class MainActivity extends Activity {
private int parseColor(String value) { private int parseColor(String value) {
try { try {
return (int) Long.parseLong(value, 16); return Color.parseColor(value);
} catch (NumberFormatException nfe) { } catch (IllegalArgumentException iae) {
return 0xFF000000; // #fff
int index = value.charAt(0) == '#' ? 1 : 0;
if (value.length() != (index + 3)) return Color.BLACK;
final StringBuilder sb = new StringBuilder(7);
sb.append("#");
sb.append(value.charAt(index)).append(value.charAt(index));
index++;
sb.append(value.charAt(index)).append(value.charAt(index));
index++;
sb.append(value.charAt(index)).append(value.charAt(index));
return parseColor(sb.toString());
} }
} }