Skip to content

Commit

Permalink
Show info on click (#132)
Browse files Browse the repository at this point in the history
* Able to search for meme information.

* Able to opt out of meme info.

* Able to show previous meme.

* Lul Dunno, sorry.

* Added documentation & bump version.

* Remove compatability problem
  • Loading branch information
Unthrottled authored Oct 30, 2021
1 parent c993d03 commit 92b1e97
Show file tree
Hide file tree
Showing 19 changed files with 258 additions and 16 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@

# AMII Changelog

## [0.13.0]

### Added

- The ability to view information about the source of a meme on click.
- `Show Previous Meme`: an action that shows the previously shown meme.

## [0.12.3]

### Fixed
Expand Down
23 changes: 22 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ waifu, husbando, and/or favorite character(s)!<br/><br/>
- [Status](#status)
- [Minimal Mode](#minimal-mode)
- [Discreet Mode](#discreet-mode)
- [Info On Click](#info-on-click)
- [Show Previous Meme](#show-previous-meme)
- [Offline Mode](#offline-mode)
- [Clear Memes](#clear-memes)
- [Rider Support](#rider-support)
Expand Down Expand Up @@ -273,7 +275,7 @@ your status bar.

## Minimal Mode

MIKU can be pretty chatty some times, especially if you are trying to figure out how to get your integration test to
MIKU can be pretty chatty sometimes, especially if you are trying to figure out how to get your integration test to
work. With `Minimal Mode` you have the ability to tell MIKU to only react to events that are different. So when your
tests fail a bunch of times, you will only see one failure reaction. However, whenever you break your build, or your
tests pass, you'll get a notification then.
Expand All @@ -291,6 +293,25 @@ and MIKU will re-appear and resume their duties as your virtual companion.
This plugin is also integrated with [The Doki Theme](https://github.com/doki-theme/doki-theme-jetbrains#discreet-mode), for the ultimate shame hiding experience.
Enabling/disabling `Discreet Mode` in The Doki Theme will enable/disable `Discrete Mode` for this plugin.

## Info On Click

Curious about the source of a reaction supplied by MIKU?
This feature is enabled by default, and you have the ability to configure it via the settings menu, or even in the information notification.
Just click inside the active meme, and you will get a notification about the source in the lower right-hand corner.
I have tried to tag as many assets as possible with accurate information.
However, there are some assets that I do not know the source for, sorry in advance if you wanted to know the anime!

**Note**: Clicking on a meme, changes the dismissal mode. [Please see this documentation for more information.](#dismissal)

![Info on click](./readmeAssets/info_on_click.gif)

## Show Previous Meme

Just in case you missed something, you now have the ability to tell MIKU, to show their previous reaction.
Whether you missed you chance to [show info on click](#info-on-click) or you just want to see the reaction again.
The `Show Previous Meme` action is accessible via
<kbd>Tools</kbd> > <kbd>AMII Options</kbd> > <kbd>Show Previous Meme</kbd>

## Offline Mode

If you ever find yourself coding without any internet, don't worry friend, you can take MIKU with you. All interactions
Expand Down
2 changes: 2 additions & 0 deletions docs/RELEASE-NOTES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
### Added

- The ability to view information about the source of a meme on click.
- `Show Previous Meme`: an action that shows the previously shown meme.
- `Discreet Mode`, when enabled MIKU will clear and not show _any_ anime in the IDE. Also, the mood in the status bar
will temporarily hide as well.
- Added 2021.3 Build support. Plugin only supports 2020.3+ builds now.
Expand Down
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

pluginGroup = io.unthrottled
pluginName_ = Anime Memes
pluginVersion = 0.12.3
pluginVersion = 0.13.0
pluginSinceBuild = 203.7148.57
pluginUntilBuild = 213.*
# Plugin Verifier integration -> https://github.com/JetBrains/gradle-intellij-plugin#plugin-verifier-dsl
Expand All @@ -15,7 +15,7 @@ platformVersion = 2021.2
platformDownloadSources = true
# Plugin Dependencies -> https://www.jetbrains.org/intellij/sdk/docs/basics/plugin_structure/plugin_dependencies.html
# Example: platformPlugins = com.intellij.java,com.jetbrains.php:203.4449.22
platformPlugins = io.acari.DDLCTheme:20.0.0
platformPlugins = io.acari.DDLCTheme:21.0.0

idePath=
#idePath=/home/alex/.local/share/JetBrains/Toolbox/apps/AndroidStudio/ch-0/203.7321754
Expand Down
Binary file added readmeAssets/info_on_click.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 11 additions & 3 deletions src/main/java/io/unthrottled/amii/config/ui/PluginSettingsUI.form
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@
</grid>
</constraints>
</vspacer>
<grid id="8cf44" layout-manager="GridLayoutManager" row-count="2" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<grid id="8cf44" layout-manager="GridLayoutManager" row-count="3" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<grid row="3" column="0" row-span="1" col-span="2" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
Expand All @@ -100,17 +100,25 @@
<children>
<component id="e60ea" class="javax.swing.JTextPane" binding="generalLinks" custom-create="true" default-binding="true">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="6" anchor="0" fill="3" indent="0" use-parent-layout="false">
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="6" anchor="0" fill="3" indent="0" use-parent-layout="false">
<preferred-size width="150" height="50"/>
</grid>
</constraints>
<properties/>
</component>
<vspacer id="3959b">
<constraints>
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
</constraints>
</vspacer>
<component id="90a8d" class="javax.swing.JCheckBox" binding="infoOnClickCheckBox" default-binding="true">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text resource-bundle="messages/AMII" key="settings.general.misc.show-info"/>
</properties>
</component>
</children>
</grid>
<vspacer id="1792f">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ public class PluginSettingsUI implements SearchableConfigurable, Configurable.No
private JSpinner maxHeightSpinner;
private JSpinner maxWidthSpinner;
private JCheckBox discreetModeCheckBox;
private JCheckBox infoOnClickCheckBox;
private PreferredCharacterPanel characterModel;
private PreferredCharacterPanel blacklistedCharacterModel;
private JBTable exitCodeTable;
Expand Down Expand Up @@ -343,6 +344,12 @@ private Optional<URI> getFilePath(String asset) {
updateDimensionCapComponents();
pluginSettingsModel.setCapDimensions(enableDimensionCappingCheckBox.isSelected());
});

infoOnClickCheckBox.setSelected(initialSettings.getInfoOnClick());
infoOnClickCheckBox.addActionListener(e ->
pluginSettingsModel.setInfoOnClick(infoOnClickCheckBox.isSelected()));


SpinnerNumberModel maxMemeHeightSpinnerModel = new SpinnerNumberModel(
config.getMaxMemeHeight(),
-1,
Expand Down Expand Up @@ -647,6 +654,7 @@ public void apply() {
config.setMinimalMode(pluginSettingsModel.getMinimalMode());
config.setDiscreetMode(pluginSettingsModel.getDiscreetMode());
config.setCapDimensions(pluginSettingsModel.getCapDimensions());
config.setInfoOnClick(pluginSettingsModel.getInfoOnClick());
config.setMaxMemeHeight(pluginSettingsModel.getMaxMemeHeight());
config.setMaxMemeWidth(pluginSettingsModel.getMaxMemeWidth());
ApplicationManager.getApplication().getMessageBus().syncPublisher(
Expand Down
28 changes: 28 additions & 0 deletions src/main/kotlin/io/unthrottled/amii/actions/PreviousMemeAction.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package io.unthrottled.amii.actions

import com.intellij.openapi.Disposable
import com.intellij.openapi.actionSystem.AnAction
import com.intellij.openapi.actionSystem.AnActionEvent
import com.intellij.openapi.project.DumbAware
import io.unthrottled.amii.memes.memeService
import io.unthrottled.amii.tools.AlarmDebouncer
import io.unthrottled.amii.tools.Logging

class PreviousMemeAction : AnAction(), DumbAware, Logging, Disposable {

companion object {
private const val DEMAND_DELAY = 250
}

private val debouncer = AlarmDebouncer<AnActionEvent>(DEMAND_DELAY)

override fun actionPerformed(e: AnActionEvent) {
val project = e.project!!
debouncer.debounce {
project.memeService().displayLastMeme()
}
}

override fun dispose() {
}
}
2 changes: 1 addition & 1 deletion src/main/kotlin/io/unthrottled/amii/assets/AssetModels.kt
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ enum class MemeAssetCategory(val value: Int) {
;

companion object {
private val mappedMemeAssetCategories = values().map { it.value to it }.toMap()
private val mappedMemeAssetCategories = values().associateBy { it.value }

fun fromValue(value: Int): MemeAssetCategory =
mappedMemeAssetCategories[value] ?: MOTIVATION
Expand Down
4 changes: 4 additions & 0 deletions src/main/kotlin/io/unthrottled/amii/config/Config.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package io.unthrottled.amii.config

import com.intellij.openapi.application.Application
import com.intellij.openapi.components.PersistentStateComponent
import com.intellij.openapi.components.ServiceManager
import com.intellij.openapi.components.State
Expand All @@ -14,6 +15,8 @@ import io.unthrottled.amii.listeners.OK_EXIT_CODE
import io.unthrottled.amii.memes.PanelDismissalOptions
import io.unthrottled.amii.tools.lt

fun Application.getConfig(): Config = this.getService(Config::class.java)

@State(
name = "Plugin-Config",
storages = [Storage("AMII.xml")]
Expand Down Expand Up @@ -41,6 +44,7 @@ class Config : PersistentStateComponent<Config>, Cloneable {
var memeVolume: Int = DEFAULT_VOLUME_LEVEL
var soundEnabled = true
var discreetMode = false
var infoOnClick = true
var discreetModeConfig = "{}"
var memeDisplayModeValue: String = PanelDismissalOptions.TIMED.toString()
var memeDisplayAnchorValue: String = NotificationAnchor.TOP_RIGHT.toString()
Expand Down
2 changes: 2 additions & 0 deletions src/main/kotlin/io/unthrottled/amii/config/PluginSettings.kt
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ data class ConfigSettingsModel(
var minimalMode: Boolean,
var discreetMode: Boolean,
var capDimensions: Boolean,
var infoOnClick: Boolean,
var maxMemeWidth: Int,
var maxMemeHeight: Int,
) {
Expand Down Expand Up @@ -62,6 +63,7 @@ object PluginSettings {
minimalMode = Config.instance.minimalMode,
discreetMode = Config.instance.discreetMode,
capDimensions = Config.instance.capDimensions,
infoOnClick = Config.instance.infoOnClick,
maxMemeWidth = Config.instance.maxMemeWidth,
maxMemeHeight = Config.instance.maxMemeHeight,
)
Expand Down
27 changes: 27 additions & 0 deletions src/main/kotlin/io/unthrottled/amii/memes/Meme.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@ package io.unthrottled.amii.memes

import com.intellij.openapi.Disposable
import com.intellij.openapi.application.ApplicationManager
import com.intellij.openapi.project.Project
import com.intellij.util.messages.Topic
import io.unthrottled.amii.assets.AudibleContent
import io.unthrottled.amii.assets.VisualMemeContent
import io.unthrottled.amii.config.Config
import io.unthrottled.amii.config.getConfig
import io.unthrottled.amii.config.ui.NotificationAnchor
import io.unthrottled.amii.events.UserEvent
import io.unthrottled.amii.memes.player.MemePlayer
Expand Down Expand Up @@ -33,24 +35,41 @@ interface MemeLifecycleListener {
// user triggered event
fun onDismiss() {}

fun onClick() {}

fun onRemoval() {}

fun onDisplay() {}
}

@Suppress("LongParameterList")
class Meme(
private val memePlayer: MemePlayer?,
private val memePanel: MemePanel,
val userEvent: UserEvent,
private val comparator: (Meme) -> Comparison,
val metadata: Map<String, Any>,
private val project: Project,
val visualMemeContent: VisualMemeContent,
) : Disposable {

fun clone(): Meme =
Meme(
memePlayer,
memePanel.clone(),
userEvent,
comparator,
metadata,
project,
visualMemeContent
)

class Builder(
private val visualMemeContent: VisualMemeContent,
private val audibleContent: AudibleContent?,
private val userEvent: UserEvent,
private val rootPane: JLayeredPane,
private val project: Project,
) {
private var notificationMode = Config.instance.notificationMode
private var notificationAnchor = Config.instance.notificationAnchor
Expand Down Expand Up @@ -106,6 +125,8 @@ class Meme(
userEvent,
memeComparator,
metaData,
project,
visualMemeContent,
)
}
}
Expand All @@ -129,6 +150,12 @@ class Meme(
}
}

override fun onClick() {
if (ApplicationManager.getApplication().getConfig().infoOnClick) {
project.memeInfoService().displayInfo(visualMemeContent)
}
}

override fun onDismiss() {
listeners.forEach { it.onDismiss() }
}
Expand Down
Loading

0 comments on commit 92b1e97

Please sign in to comment.