Skip to content

Commit

Permalink
Merge branch 'main' into satellite-map
Browse files Browse the repository at this point in the history
  • Loading branch information
Feodor0090 committed Jun 25, 2023
2 parents 9b3509e + 506e4dd commit c814844
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 25 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
name: CI
on: [push, pull_request]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
build:
runs-on: ubuntu-20.04
Expand Down
2 changes: 2 additions & 0 deletions src/mahomaps/Settings.java
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ public static synchronized boolean Read() {
cacheMode = j.getInt("cache", 1);
proxyTiles = j.getBoolean("proxy_tiles");
proxyApi = j.getBoolean("proxy_api");
proxyServer = j.getString("proxy_server", proxyServer);
uiSize = j.getInt("ui_size", 0);
apiLang = j.getInt("lang", 0);
uiLang = j.getInt("ui_lang", 0);
Expand Down Expand Up @@ -128,6 +129,7 @@ public static String Serialize() {
j.put("cache", cacheMode);
j.put("proxy_tiles", proxyTiles);
j.put("proxy_api", proxyApi);
j.put("proxy_server", proxyServer);
j.put("ui_size", uiSize);
j.put("lang", apiLang);
j.put("ui_lang", uiLang);
Expand Down
43 changes: 26 additions & 17 deletions src/mahomaps/map/Line.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ public class Line {

private int forZoom = -1;
private int[] cache = null;
private int thickness = 2;
public int drawFrom = 0;

public Line(Geopoint start, Geopoint[] source) {
Expand Down Expand Up @@ -38,6 +39,12 @@ private void Invalidate(MapState ms) {
}
cache = new int[(ti + 1) * 2];
System.arraycopy(temp, 0, cache, 0, cache.length);
if (forZoom <= 7)
thickness = 0;
else if (forZoom <= 14)
thickness = 1;
else
thickness = 2;
}

public void Invalidate() {
Expand All @@ -63,25 +70,27 @@ public synchronized void Draw(Graphics g, MapCanvas map) {
if (!vis1 && !vis2)
continue;
g.setColor(0xff0000);
{
// first point
// draw nothing?
}
{
if (thickness == 0) {
g.drawLine(x1, y1, x2, y2);
} else {
// second point
g.fillRect(x2 - 1, y2 - 2, 2, 4);
g.fillRect(x2 - 2, y2 - 1, 4, 2);
}
{
// line
final int hor = Math.abs(x2 - x1);
final int ver = Math.abs(y2 - y1);
if (hor > ver) {
g.fillTriangle(x1, y1 - 2, x1, y1 + 2, x2, y2 + 2);
g.fillTriangle(x1, y1 - 2, x2, y2 - 2, x2, y2 + 2);
if (thickness == 1) {
g.fillRect(x2 - 1, y2 - 1, 2, 2);
} else {
g.fillTriangle(x1 - 2, y1, x1 + 2, y1, x2 - 2, y2);
g.fillTriangle(x2 + 2, y2, x1 + 2, y1, x2 - 2, y2);
g.fillRect(x2 - (thickness >> 1), y2 - thickness, thickness, thickness << 1);
g.fillRect(x2 - thickness, y2 - (thickness >> 1), thickness << 1, thickness);
}
// line
{
final int hor = Math.abs(x2 - x1);
final int ver = Math.abs(y2 - y1);
if (hor > ver) {
g.fillTriangle(x1, y1 - thickness, x1, y1 + thickness, x2, y2 + thickness);
g.fillTriangle(x1, y1 - thickness, x2, y2 - thickness, x2, y2 + thickness);
} else {
g.fillTriangle(x1 - thickness, y1, x1 + thickness, y1, x2 - thickness, y2);
g.fillTriangle(x2 + thickness, y2, x1 + thickness, y1, x2 - thickness, y2);
}
}
}
}
Expand Down
23 changes: 22 additions & 1 deletion src/mahomaps/screens/BookmarksScreen.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ public class BookmarksScreen extends List implements CommandListener {

private Command from = new Command("Отсюда", Command.ITEM, 0);
private Command to = new Command("Сюда", Command.ITEM, 1);
private Command del = new Command("Удалить", Command.ITEM, 1);
private Command del = new Command("Удалить", Command.ITEM, 2);
private Command rename = new Command("Переименовать", Command.ITEM, 2);

public BookmarksScreen() {
super("Закладки", Choice.IMPLICIT);
Expand All @@ -36,6 +37,7 @@ public BookmarksScreen() {
addCommand(from);
addCommand(to);
addCommand(del);
addCommand(rename);
}
setCommandListener(this);
}
Expand Down Expand Up @@ -109,6 +111,10 @@ private static void Save(JSONArray arr) {

public void commandAction(Command c, Displayable d) {
if (c == MahoMapsApp.back) {
if (d instanceof TextBox) {
MahoMapsApp.BringSubScreen(this);
return;
}
MahoMapsApp.BringMap();
return;
}
Expand All @@ -119,12 +125,27 @@ public void commandAction(Command c, Displayable d) {
if (n == -1)
return;

if (c == MahoMapsApp.ok) {
// будем надеяться что фокус элемента не сбросится пока юзер будет вводить текст
String s = ((TextBox) d).getString();
set(n, s, null);
list.getObject(n).put("name", s);
return;
}
if (c == del) {
list.remove(n);
delete(n);
Save(list);
return;
}
if (c == rename) {
final TextBox tb = new TextBox("Название закладки?", getString(n), 100, 0);
tb.addCommand(MahoMapsApp.back);
tb.addCommand(MahoMapsApp.ok);
tb.setCommandListener(this);
MahoMapsApp.BringSubScreen(tb);
return;
}
JSONObject obj = list.getObject(n);
Geopoint p = new Geopoint(obj.getDouble("lat"), obj.getDouble("lon"));
if (c == SELECT_COMMAND) {
Expand Down
21 changes: 14 additions & 7 deletions src/mahomaps/screens/SettingsScreen.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.Form;
import javax.microedition.lcdui.Image;
import javax.microedition.lcdui.TextField;

import mahomaps.MahoMapsApp;
import mahomaps.Settings;
Expand All @@ -28,8 +29,9 @@ public class SettingsScreen extends Form implements CommandListener {
private ChoiceGroup download = new ChoiceGroup(MahoMapsApp.text[54], Choice.MULTIPLE,
new String[] { MahoMapsApp.text[18] }, null);
private ChoiceGroup map = new ChoiceGroup("Map", Choice.EXCLUSIVE, new String[] { "Scheme", "Satellite" }, null);
private ChoiceGroup proxyTiles = new ChoiceGroup(MahoMapsApp.text[19], Choice.POPUP,
new String[] { MahoMapsApp.text[18], "nnchan.ru", }, null);
private ChoiceGroup proxyUsage = new ChoiceGroup(MahoMapsApp.text[19], Choice.MULTIPLE,
new String[] { "Proxy tiles", "Proxy API", }, null);
private TextField proxyServer = new TextField("Proxy prefix", "", 256, TextField.URL);
private ChoiceGroup uiSize = new ChoiceGroup(MahoMapsApp.text[56], Choice.POPUP,
new String[] { MahoMapsApp.text[57], "50x50", "30x30" }, null);
private ChoiceGroup lang = new ChoiceGroup(MahoMapsApp.text[58], Choice.POPUP,
Expand Down Expand Up @@ -71,13 +73,13 @@ public SettingsScreen() {
tileInfo.setSelectedIndex(Settings.drawDebugInfo ? 1 : 0, true);
cache.setSelectedIndex(Settings.cacheMode, true);
download.setSelectedIndex(0, Settings.allowDownload);
proxyTiles.setSelectedIndex(Settings.proxyTiles ? 1 : 0, true);
// апи отслеживается отдельно, однако предполагается что оно включено вместе с
// тайлами.
map.setSelectedIndex(Settings.map, true);
proxyUsage.setSelectedIndex(0, Settings.proxyTiles);
proxyUsage.setSelectedIndex(1, Settings.proxyApi);
uiSize.setSelectedIndex(Settings.uiSize, true);
lang.setSelectedIndex(Settings.apiLang, true);
uiLang.setSelectedIndex(Settings.uiLang, true);
map.setSelectedIndex(Settings.map, true);
proxyServer.setString(Settings.proxyServer);

append(focusZoom);
append(geoLook);
Expand All @@ -86,7 +88,8 @@ public SettingsScreen() {
append(cache);
append(download);
append(map);
append(proxyTiles);
append(proxyUsage);
append(proxyServer);
append(uiSize);
append(lang);
append(uiLang);
Expand All @@ -105,6 +108,9 @@ private void Apply() {
Settings.allowDownload = download.isSelected(0);
Settings.proxyTiles = proxyTiles.getSelectedIndex() == 1;
Settings.proxyApi = proxyTiles.getSelectedIndex() == 1;
Settings.allowDownload = download.isSelected(0);
Settings.proxyTiles = proxyUsage.isSelected(0);
Settings.proxyApi = proxyUsage.isSelected(1);
Settings.uiSize = uiSize.getSelectedIndex();
Settings.apiLang = lang.getSelectedIndex();
Settings.uiLang = uiLang.getSelectedIndex();
Expand All @@ -115,6 +121,7 @@ private void Apply() {
MahoMapsApp.tiles.ForceMissingDownload();
}
Settings.map = map.getSelectedIndex();
Settings.proxyServer = proxyServer.getString();
}

public void commandAction(Command c, Displayable d) {
Expand Down

0 comments on commit c814844

Please sign in to comment.