-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(chat): shift click damage buttons for modifier #276 #277
Open
Khunkurisu
wants to merge
7
commits into
the-metalworks:release-0.3.0
Choose a base branch
from
Khunkurisu:feat/shift-click-damage-buttons-for-modifier-#276
base: release-0.3.0
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 6 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
89dcab9
feat(chat): implement shift+click dialog for damage/healing chat buttons
Khunkurisu eea59bf
feat(chat): implement shift+click dialog for focus chat button
Khunkurisu 199289b
chore(localization): add localization strings for shift+click dialog …
Khunkurisu 3dc8e01
fix(standards): fix using tabs instead of spaces on new localization …
Khunkurisu 8fb2a87
refactor(chat/dialog): rework modifier dialog to a class and use a te…
Khunkurisu 11a4c71
refactor(chat/dialog): make use of a keybinding instead of hardcoding…
Khunkurisu e7a933e
refactor(chat/dialog): add setting for damage card dialog to show/ski…
Khunkurisu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
79 changes: 79 additions & 0 deletions
79
src/system/applications/actor/dialogs/damage-card-modifier.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
import { SYSTEM_ID } from '@src/system/constants'; | ||
import { TEMPLATES } from '@src/system/utils/templates'; | ||
|
||
// Constants | ||
const TEMPLATE = `systems/${SYSTEM_ID}/templates/${TEMPLATES.DIALOG_CHAT_MODIFY_DAMAGE}`; | ||
|
||
interface DamageModifierDialogOptions { | ||
/** | ||
* Whether this is healing. | ||
*/ | ||
isHealing: boolean; | ||
|
||
/** | ||
* Who is tending to this actor? | ||
*/ | ||
action: string; | ||
} | ||
|
||
export class DamageModifierDialog extends foundry.applications.api.DialogV2 { | ||
private constructor( | ||
private isHealing: boolean, | ||
private action: string, | ||
private resolve: (modifier: number) => void, | ||
content: string, | ||
) { | ||
super({ | ||
window: { | ||
title: `COSMERE.ChatMessage.ModifierDialog.${action === 'reduce-focus' ? 'FocusTitle' : isHealing ? 'HealingTitle' : 'DamageTitle'}`, | ||
}, | ||
content, | ||
buttons: [ | ||
{ | ||
label: 'GENERIC.Button.Confirm', | ||
action: 'submit', | ||
default: true, | ||
// NOTE: Callback must be async | ||
// eslint-disable-next-line @typescript-eslint/require-await | ||
callback: async () => this.onContinue(), | ||
}, | ||
], | ||
}); | ||
} | ||
|
||
/* --- Statics --- */ | ||
|
||
public static async show( | ||
options: DamageModifierDialogOptions = { | ||
isHealing: false, | ||
action: '', | ||
}, | ||
): Promise<number> { | ||
// Render dialog inner HTML | ||
const content = await renderTemplate(TEMPLATE, { | ||
isHealing: options.isHealing, | ||
action: options.action, | ||
}); | ||
|
||
// Render dialog and wrap as promise | ||
return new Promise((resolve) => { | ||
void new DamageModifierDialog( | ||
options.isHealing, | ||
options.action, | ||
resolve, | ||
content, | ||
).render(true); | ||
}); | ||
} | ||
|
||
/* --- Actions --- */ | ||
|
||
private onContinue() { | ||
const form = this.element.querySelector('form')! as HTMLFormElement & { | ||
modifier: HTMLInputElement; | ||
}; | ||
|
||
// Resolve | ||
this.resolve(form.modifier.value ? form.modifier.valueAsNumber : 0); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<form> | ||
<div class="form-group"> | ||
<label>{{ localize "GENERIC.Modifier"}}</label> | ||
<div class="form-fields"> | ||
<input name="modifier" type="number" step="1" placeholder="+0" autofocus> | ||
</div> | ||
</div> | ||
</form> | ||
MangoFVTT marked this conversation as resolved.
Show resolved
Hide resolved
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm of the opinion that it doesn't need to be a separate keybinding and can just use the generic Skip/Show Dialog. For a couple of reasons:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't disagree with your points about binding creep necessarily, except that I absolutely do not think the two keybinds should be the same. They're two entirely different functions in different contexts, and it feels incredibly wrong to have them tied together.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The only way I can personally see the skip/show dialog keybind being appropriate for this context is if the dialog appearing is the default behavior, and much like the roll dialog, we have a setting to allow it to be skipped by default.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or the inverse. Have it skipped by default but a setting to show it by default. Then the keybind being "skip/show dialog" works as a catch-all.