Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,7 @@ private void launchAccount(final Account account, final Delay delay) throws Inte
openedBaseAppWindow.selectServer();
openedBaseAppWindow.chooseCharacter();
logger.info("account {} ({}) has been launched successfully", account.name(), account.login());
//before minimizing delay because of window high load
delay.sleep(settings.targetBaseAppSettings().afterLaunchAccountDelay(), TimeUnit.MILLISECONDS);
openedBaseAppWindow.checkInGameWindowRendered();
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,4 +109,9 @@ public interface TargetBaseAppSettings {

KeyShortcut openMenuHotkey();

KeyShortcut openAccountInfoHotkey();

int accountInfoPopupRenderingTimeout();

int accountInfoPopupRenderingDelay();
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,6 @@ public interface TargetBaseAppStamps {
Stamp startButton();

Stamp dailyTrackerPopupCaption();

Stamp accountInfoPopupCaption();
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,6 @@ public interface RestoredBaseAppWindow {
void selectServer() throws InterruptedException;

void chooseCharacter() throws InterruptedException;

void checkInGameWindowRendered() throws InterruptedException;
}
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
</modules>

<properties>
<revision>2.0.1-rc.0.1.0</revision>
<revision>2.0.1-new-base-window-check-order.0.1.1</revision>
<app.build.properties.filename>app-build.properties</app.build.properties.filename>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>16</maven.compiler.source>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,9 @@ enum TargetBaseApp implements SettingKey {
SettingObtainWays.pressHotkey),
openMenuHotkey(KeyShortcut.class,
"Hot key to open menu popup",
SettingObtainWays.pressHotkey),
openAccountInfoHotkey(KeyShortcut.class,
"Hot key to open account info popup",
SettingObtainWays.pressHotkey);

private final SettingData settingData;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ enum TargetBaseApp implements StampKey {
serverLineUnselected("Base window - Select server page - Server line; Unselected; Base scale"),
needRestartPopup("Need restart popup; Base scale"),
disconnectedPopup("Disconnected popup; Base scale"),
dailyTrackerPopupCaption("In-game daily tracker popup caption; Base scale");
dailyTrackerPopupCaption("In-game daily tracker popup caption; Base scale"),
accountInfoPopupCaption("Account info popup caption; Base scale");

private final SettingData settingData;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
import midorum.melbone.model.persistence.SettingStorage;
import midorum.melbone.model.settings.PropertiesProvider;
import midorum.melbone.model.settings.SettingsProvider;
import midorum.melbone.settings.SettingKeys;
import midorum.melbone.settings.StampKeys;
import midorum.melbone.settings.internal.management.experimental.TaskStorageImpl;
import midorum.melbone.settings.internal.storage.KeyValueStorage;
import midorum.melbone.settings.internal.storage.StorageHolder;
Expand All @@ -14,6 +16,9 @@
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import java.util.Arrays;
import java.util.stream.Stream;

public class SettingsFactoryInternal implements AutoCloseable {

private static final int VERSION = 1;
Expand All @@ -32,6 +37,7 @@ private SettingsFactoryInternal(final SettingPropertyNaming settingPropertyNamin
this.settingStorage = new SettingStorageImpl(keyValueStorage);
this.accountStorage = new AccountStorageImpl(keyValueStorage);
this.taskStorage = new TaskStorageImpl();
checkAllSettingsState();
}

public KeyValueStorage getKeyValueStorage() {
Expand All @@ -54,7 +60,9 @@ public SettingsProvider settingsProvider() {
return settingsProvider;
}

public PropertiesProvider propertiesProvider() {return propertiesProvider;}
public PropertiesProvider propertiesProvider() {
return propertiesProvider;
}

private KeyValueStorage openKeyValueStorage(final SettingPropertyNaming settingPropertyNaming, final boolean plainMode) {
final StorageHolder storageHolder = new StorageHolder(propertiesProvider, settingPropertyNaming, plainMode);
Expand All @@ -81,8 +89,17 @@ public void close() throws Exception {
keyValueStorage.close();
}

private void checkAllSettingsState() {
if (!propertiesProvider.isModeSet("check_settings_on_start")) return;
Stream.concat(Arrays.stream(SettingKeys.values()), Arrays.stream(StampKeys.values())).forEach(key ->
settingStorage.read(key).ifPresentOrElse(o -> logger.info("{} is kept in storage", key),
() -> key.internal().defaultValue().ifPresentOrElse(o -> logger.info("{} used default value", key),
() -> logger.warn("{} not found in storage nor has default value", key))));
}

public static class Builder {


private SettingPropertyNaming settingPropertyNaming;
private boolean plainMode = false;
private String propertyFileName;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ public int checkStartButtonRenderingDelay() {

@Override
public int baseWindowRenderingTimeout() {
return 180_000;
return 300_000;
}

@Override
Expand Down Expand Up @@ -247,6 +247,16 @@ public int checkDailyTrackerPopupRenderingDelay() {
return 500;
}

@Override
public int accountInfoPopupRenderingTimeout() {
return 2_000;
}

@Override
public int accountInfoPopupRenderingDelay() {
return 500;
}

@Override
public long afterLaunchAccountDelay() {
return (long) getValue(SettingKeys.TargetBaseApp.afterLaunchAccountDelay);
Expand All @@ -271,4 +281,9 @@ public KeyShortcut cancelCurrentOperationHotkey() {
public KeyShortcut openMenuHotkey() {
return (KeyShortcut) getValue(SettingKeys.TargetBaseApp.openMenuHotkey);
}

@Override
public KeyShortcut openAccountInfoHotkey() {
return (KeyShortcut) getValue(SettingKeys.TargetBaseApp.openAccountInfoHotkey);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,9 @@ public Stamp startButton() {
public Stamp dailyTrackerPopupCaption() {
return getStamp(StampKeys.TargetBaseApp.dailyTrackerPopupCaption);
}

@Override
public Stamp accountInfoPopupCaption() {
return getStamp(StampKeys.TargetBaseApp.accountInfoPopupCaption);
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package midorum.melbone.ui.internal.util;

import com.midorum.win32api.facade.Rectangle;

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
Expand Down Expand Up @@ -37,7 +38,7 @@ private JFrame constructFrame() {
final Point locationOnScreen = frame.getLocationOnScreen();
final Dimension size = frame.getSize();
frame.dispose();
this.consumer.accept(Optional.of(new Rectangle(locationOnScreen.x, locationOnScreen.y, size.width, size.height)));
this.consumer.accept(Optional.of(new Rectangle(locationOnScreen.x, locationOnScreen.y, locationOnScreen.x + size.width, locationOnScreen.y + size.height)));
};

final Action closeFrame = () -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import com.midorum.win32api.facade.IMouse;
import com.midorum.win32api.facade.IWindow;
import com.midorum.win32api.struct.PointFloat;
import com.midorum.win32api.win32.Win32VirtualKey;
import dma.flow.Waiting;
import dma.function.ConsumerThrowing;
import dma.util.Delay;
Expand Down Expand Up @@ -160,18 +159,16 @@ private void checkIfInGameWindowRendered() throws InterruptedException {
}

private boolean waitBaseWindowRendering() throws InterruptedException {
log.info("waiting for base window rendering");
final boolean result = new Waiting()
log.info("wait for base window rendering");
return new Waiting()
.timeout(settings.targetBaseAppSettings().baseWindowRenderingTimeout(), TimeUnit.MILLISECONDS)
.withDelay(settings.targetBaseAppSettings().checkBaseWindowRenderingDelay(), TimeUnit.MILLISECONDS)
.doOnEveryFailedIteration(i -> log.debug("{}: base window has not rendered yet", new DurationFormatter(i.fromStart()).toStringWithoutZeroParts()))
.waitForBoolean(this::waitForMenuRendering);// open menu
if (result) window.getKeyboard().enterHotKey(settings.targetBaseAppSettings().openMenuHotkey().toHotKey());// close menu
return result;
.waitForBoolean(this::checkAccountInfoRendering);
}

private Optional<Stamp> waitDisconnectedPopupRendering() throws InterruptedException {
log.debug("waiting for disconnected popup rendering");
log.debug("wait for disconnected popup rendering");
final IMouse mouse = getMouse();
final Stamp checkingStamp = stamps.targetBaseApp().disconnectedPopup();
final Optional<Stamp> foundStamp = new Waiting()
Expand Down Expand Up @@ -442,6 +439,33 @@ private boolean closeDailyTrackerPopupAndCheckRendering(final IMouse mouse) thro
return notRendered;
}

private boolean checkAccountInfoRendering() throws InterruptedException {
log.info("check account info rendering");
final Optional<Stamp> maybe = openAccountInfoPopup();
if (maybe.isPresent()) {
window.getKeyboard().enterHotKey(settings.targetBaseAppSettings().openAccountInfoHotkey().toHotKey());
return true;
}
return false;
}

private Optional<Stamp> openAccountInfoPopup() throws InterruptedException {
log.info("wait for account info popup rendering");
final IKeyboard keyboard = window.getKeyboard();
final Stamp checkingStamp = stamps.targetBaseApp().accountInfoPopupCaption();
final HotKey hotKey = settings.targetBaseAppSettings().openAccountInfoHotkey().toHotKey();
final Optional<Stamp> maybeStamp = new Waiting()
.timeout(settings.targetBaseAppSettings().accountInfoPopupRenderingTimeout(), TimeUnit.MILLISECONDS)
.withDelay(settings.targetBaseAppSettings().accountInfoPopupRenderingDelay(), TimeUnit.MILLISECONDS)
.doOnEveryFailedIteration(i -> {
log.debug("{}: account info popup has not rendered yet", new DurationFormatter(i.fromStart()).toStringWithoutZeroParts());
keyboard.enterHotKey(hotKey);
})
.waitFor(() -> commonWindowService.getStampValidator().validateStampWholeData(this.window, checkingStamp));
maybeStamp.ifPresent(stamp -> log.debug("found stamp {}", stamp.key().internal().groupName() + "." + stamp.key().name()));
return maybeStamp;
}

private BrokenWindowException getBrokenWindowException(final String message, Stamp... stamps) {
final String marker = Long.toString(System.currentTimeMillis());
final BrokenWindowException exception = new BrokenWindowException(message + " (marker=" + marker + ")");
Expand Down Expand Up @@ -512,6 +536,12 @@ public void chooseCharacter() throws InterruptedException {

log.info("character has been selected");
}

@Override
public void checkInGameWindowRendered() throws InterruptedException {
checkIfNotDisconnected();
checkIfInGameWindowRendered();
}
}

private class InGameBaseAppWindowImpl implements InGameBaseAppWindow {
Expand Down
Loading