Skip to content

Commit

Permalink
Merge branch 'release/v0.6.15-alpha'
Browse files Browse the repository at this point in the history
  • Loading branch information
micheljung committed Jul 3, 2016
2 parents 7856ba0 + a9646a8 commit a080398
Show file tree
Hide file tree
Showing 59 changed files with 635 additions and 314 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@
*.jpg binary
*.mp3 binary
*.zip binary
*.exe binary
3 changes: 3 additions & 0 deletions .idea/codeStyleSettings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 14 additions & 17 deletions downlords-faf-client.iml → .idea/modules/downlords-faf-client.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/runConfigurations/FAF_Client_Prod.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/runConfigurations/FAF_Client_Prod_NoUpdate.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/runConfigurations/FAF_Client_Test.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file removed LIBEAY32.dll
Binary file not shown.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ apply plugin: 'distribution'
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8

version = '0.6.14-alpha'
version = '0.6.15-alpha'

class HttpBuilder extends HTTPBuilder {

Expand Down
6 changes: 4 additions & 2 deletions downlords-faf-client.install4j
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
<versionLine x="370" y="273" text="v${compiler:sys.version}" fontSize="16" fontColor="255,255,255" bold="true" />
</text>
</splashScreen>
<java mainClass="com.faforever.client.Main" vmParameters="-javaagent:lib/webview-patch-agent.jar" arguments="" allowVMPassthroughParameters="true" preferredVM="client" bundleRuntime="true">
<java mainClass="com.faforever.client.Main" vmParameters="-javaagent:lib/webview-patch-agent.jar -Duid.dir=lib" arguments="" allowVMPassthroughParameters="true" preferredVM="client" bundleRuntime="true">
<classPath>
<scanDirectory location="lib" failOnError="true" />
</classPath>
Expand Down Expand Up @@ -447,7 +447,9 @@
<excludedLaunchers />
<excludedBeans />
<overriddenPrincipalLanguage id="en" customLocalizationFile="" />
<exclude />
<exclude>
<entry location="lib/uid" fileType="regular" />
</exclude>
<variables />
<autoUpdate useMinUpdatableVersion="false" minUpdatableVersion="" useMaxUpdatableVersion="false" maxUpdatableVersion="">
<commentFiles />
Expand Down
Binary file removed mfc100u.dll
Binary file not shown.
Binary file removed msvcp100.dll
Binary file not shown.
2 changes: 2 additions & 0 deletions src/main/java/com/faforever/client/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import com.faforever.client.main.MainController;
import com.faforever.client.preferences.PreferencesService;
import com.faforever.client.theme.ThemeService;
import com.faforever.client.util.SslUtil;
import com.google.common.annotations.VisibleForTesting;
import javafx.application.Application;
import javafx.scene.image.Image;
Expand All @@ -32,6 +33,7 @@ public Main() {
public void start(Stage stage) {
Font.loadFont(getClass().getResourceAsStream("/font/fontawesome-webfont.ttf"), 0);
JavaFxUtil.fixTooltipDuration();
SslUtil.loadTruststores();

initApplicationContext(stage);
initStage(stage, context.getBean(ThemeService.class));
Expand Down
104 changes: 10 additions & 94 deletions src/main/java/com/faforever/client/chat/AbstractChatTabController.java
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,11 @@
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;

import static com.faforever.client.chat.SocialStatus.FOE;
import static com.faforever.client.chat.SocialStatus.FRIEND;
import static com.faforever.client.chat.SocialStatus.SELF;
import static com.google.common.html.HtmlEscapers.htmlEscaper;
import static java.util.Locale.US;
import static java.util.regex.Pattern.CASE_INSENSITIVE;
import static javafx.scene.AccessibleAttribute.ITEM_AT_INDEX;

Expand Down Expand Up @@ -156,6 +154,9 @@ public abstract class AbstractChatTabController {
MainController mainController;
@Resource
ThemeService themeService;
@Resource
AutoCompletionHelper autoCompletionHelper;

private boolean isChatReady;
private WebEngine engine;
private double lastMouseX;
Expand All @@ -168,14 +169,7 @@ public abstract class AbstractChatTabController {
* Either a channel like "#aeolus" or a user like "Visionik".
*/
private String receiver;
/**
* Stores possible values for autocompletion (when strted typing a name, then pressing TAB). This value needs to be
* set to {@code null} after the message has been sent or the caret has been moved in order to restart the
* autocompletion on next TAB press.
*/
private List<String> possibleAutoCompletions;
private int nextAutoCompleteIndex;
private String autoCompletePartialName;

private Pattern mentionPattern;
private Popup playerCardTooltip;
private Tooltip linkPreviewTooltip;
Expand Down Expand Up @@ -240,6 +234,10 @@ protected void incrementUnreadMessagesCount(int delta) {
}
}

public String getReceiver() {
return receiver;
}

public void setReceiver(String receiver) {
this.receiver = receiver;
}
Expand All @@ -258,6 +256,8 @@ void postConstruct() {
);
stage.focusedProperty().addListener(new WeakChangeListener<>(resetUnreadMessagesListener));
getRoot().selectedProperty().addListener(new WeakChangeListener<>(resetUnreadMessagesListener));

autoCompletionHelper.bindTo(getMessageTextField());
}

/**
Expand Down Expand Up @@ -380,12 +380,6 @@ protected JSObject getJsObject() {
return (JSObject) engine.executeScript("window");
}

private void resetAutoCompletion() {
possibleAutoCompletions = null;
nextAutoCompleteIndex = -1;
autoCompletePartialName = null;
}

/**
* Called from JavaScript when user hovers over a user name.
*/
Expand Down Expand Up @@ -475,84 +469,6 @@ void onSendMessage() {
} else {
sendMessage();
}

resetAutoCompletion();
}

@FXML
void onKeyPressed(KeyEvent keyEvent) {
if (!keyEvent.isControlDown() && keyEvent.getCode() == KeyCode.TAB) {
keyEvent.consume();
autoComplete();
}
}

// TODO extract to helper class
private void autoComplete() {
TextInputControl messageTextField = getMessageTextField();

if (messageTextField.getText().isEmpty()) {
return;
}

if (possibleAutoCompletions == null) {
initializeAutoCompletion(messageTextField);

if (possibleAutoCompletions.isEmpty()) {
// There are no autocompletion matches
resetAutoCompletion();
return;
}

// It's the first autocomplete event at this location, just replace the text with the first user name
messageTextField.selectPreviousWord();
messageTextField.replaceSelection(possibleAutoCompletions.get(nextAutoCompleteIndex++));
return;
}

// At this point, it's a subsequent auto complete event
String wordBeforeCaret = getWordBeforeCaret(messageTextField);

/*
* We have to check if the previous word is the one we auto completed. If not we reset and start all over again
* as the user started auto completion on another word.
*/
if (!wordBeforeCaret.equals(possibleAutoCompletions.get(nextAutoCompleteIndex - 1))) {
resetAutoCompletion();
autoComplete();
return;
}

if (possibleAutoCompletions.size() == 1) {
// No need to cycle since there was only one match
return;
}

if (possibleAutoCompletions.size() <= nextAutoCompleteIndex) {
// Start over again in order to cycle
nextAutoCompleteIndex = 0;
}

messageTextField.selectPreviousWord();
messageTextField.replaceSelection(possibleAutoCompletions.get(nextAutoCompleteIndex++));
}

private void initializeAutoCompletion(TextInputControl messageTextField) {
possibleAutoCompletions = new ArrayList<>();

autoCompletePartialName = getWordBeforeCaret(messageTextField);
if (autoCompletePartialName.isEmpty()) {
return;
}

nextAutoCompleteIndex = 0;

possibleAutoCompletions.addAll(
playerService.getPlayerNames().stream()
.filter(playerName -> playerName.toLowerCase(US).startsWith(autoCompletePartialName.toLowerCase()))
.sorted()
.collect(Collectors.toList())
);
}

private String getWordBeforeCaret(TextInputControl messageTextField) {
Expand Down
Loading

0 comments on commit a080398

Please sign in to comment.