Skip to content

Commit

Permalink
Rename markDirty -> markTooltipDirty (CleanroomMC#24)
Browse files Browse the repository at this point in the history
(cherry picked from commit eadf5f0)
  • Loading branch information
miozune committed Aug 24, 2023
1 parent f1b4332 commit ea596f3
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -139,10 +139,9 @@ default boolean canHover() {
}

/**
* Marks this widget as dirty.
* Mainly used for the tooltip.
* Marks tooltip for this widget as dirty.
*/
void markDirty();
void markTooltipDirty();

/**
* @return the parent of this widget
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public boolean canBeSeen(IViewportStack stack) {
}

@Override
public void markDirty() {
public void markTooltipDirty() {
}

@Override
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/cleanroommc/modularui/widget/Widget.java
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ public void initialiseSyncHandler(GuiSyncManager syncHandler) {
throw new IllegalStateException("SyncHandler of type " + type + " is not valid for " + getClass().getName() + ", with key " + this.syncKey);
}
if (this.syncHandler instanceof ValueSyncHandler && ((ValueSyncHandler<?>) this.syncHandler).getChangeListener() == null) {
((ValueSyncHandler<?>) this.syncHandler).setChangeListener(this::markDirty);
((ValueSyncHandler<?>) this.syncHandler).setChangeListener(this::markTooltipDirty);
}
}
}
Expand Down Expand Up @@ -217,7 +217,7 @@ public boolean isValid() {
}

@Override
public void markDirty() {
public void markTooltipDirty() {
if (this.tooltip != null) {
this.tooltip.markDirty();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,8 @@ public boolean hasTooltip() {
}

@Override
public void markDirty() {
super.markDirty();
public void markTooltipDirty() {
super.markTooltipDirty();
for (Tooltip tooltip : this.stateTooltip) {
tooltip.markDirty();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,15 +175,15 @@ public boolean onMouseScroll(ModularScreen.UpOrDown scrollDirection, int amount)
@Override
public @NotNull Result onKeyPressed(char typedChar, int keyCode) {
if (keyCode == Keyboard.KEY_LSHIFT || keyCode == Keyboard.KEY_RSHIFT) {
markDirty();
markTooltipDirty();
}
return Interactable.super.onKeyPressed(typedChar, keyCode);
}

@Override
public boolean onKeyRelease(char typedChar, int keyCode) {
if (keyCode == Keyboard.KEY_LSHIFT || keyCode == Keyboard.KEY_RSHIFT) {
markDirty();
markTooltipDirty();
}
return Interactable.super.onKeyRelease(typedChar, keyCode);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ private void checkString() {
TextRenderer.SHARED.setScale(getScale());
this.line = TextRenderer.SHARED.line(s);
this.scroll = 0;
markDirty();
markTooltipDirty();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ public List<String> getText() {
}

public void onChanged() {
this.textFieldWidget.markDirty();
this.textFieldWidget.markTooltipDirty();
}

public String getSelectedText() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public boolean isValidSyncHandler(SyncHandler syncHandler) {
if (syncHandler instanceof IStringValue && syncHandler instanceof ValueSyncHandler) {
this.stringValue = (IStringValue<?>) syncHandler;
((ValueSyncHandler<?>) this.stringValue).setChangeListener(() -> {
markDirty();
markTooltipDirty();
setText(this.stringValue.getValue().toString());
});
return true;
Expand Down Expand Up @@ -129,7 +129,7 @@ public void onRemoveFocus(GuiContext context) {
this.handler.getText().add(this.validator.apply(""));
} else if (this.handler.getText().size() == 1) {
this.handler.getText().set(0, this.validator.apply(this.handler.getText().get(0)));
markDirty();
markTooltipDirty();
} else {
throw new IllegalStateException("TextFieldWidget can only have one line!");
}
Expand Down

0 comments on commit ea596f3

Please sign in to comment.