Giter Site home page Giter Site logo

gudboinero / primedkeys Goto Github PK

View Code? Open in Web Editor NEW
5.0 2.0 1.0 5.6 MB

A simple gui screen for point and click macros! Useful for people drawing on 2-in-1 laptops or if your computer pen doesn't work as intended.

License: MIT License

GDB 0.01% C++ 57.00% C 42.64% HTML 0.03% Objective-C 0.32%
imgui opengl sdl2 art-tool standalone-app

primedkeys's Issues

Optimize And/Or Replace `crap_hash`

Currently we have a system for our texture cache, using the file path to the texture plus all of the shader file paths concatenated together. We store that in a map, this ensures that apple.png is different than apple.png with shine.glsl applied to it.

Tex GetTextureID(const std::string file_path, std::vector<std::string> shader_paths)
{
std::string crap_hash = file_path;
if (&shader_paths)
{
for (const auto& shader_path : shader_paths) {
crap_hash += ";" + shader_path;
}
}
if (auto& t = tex_cache[crap_hash]; !&t.id)
return t;
else
{
LoadTextureFromFile(file_path.data(), (GLuint*)(void*)&t.id, &t.width, &t.height, shader_paths);
tex_cache[crap_hash] = t;
return t;
}
}

It's quite clear that this is not efficient, it works for now, and that's all that matters. However eventually we will need this fixed if we would like to use more textures and shaders. Seeing as our keys will be at least 30-40 characters long each. Nobody wants that. It's called crap_hash for a reason...

Running Macros

Create a module that reads data from a JSON file which would look like so:

[ // List of macro objects
    {
        "name": "undo", // Name of macro
        "inputs": [ // List of key ups and key downs as well as scancodes
            { 
                "key": 0, // Which key was pressed
                "action": 0, // Up or down
            }
        ]
    },
    {
        "name": "redo",
        "inputs": [ ... ]
    }
]

Then through a function call. Allow calling a specific macro based on their name. RunMacro("path/to_my/file.json", "undo"); or something alike. This path to the json file should default to the pcs config files.

Config files will be something we work on later, for now we should just simulate the files being wherever we need them to be for testing purposes.

Separate `ShowMacroMenu`

Bring the ShowMacroMenu method into it's own file, inside src/gui. Ensure it is within the gui namespace.

`MacroManager::LoadMacros` file verify and fix

Inside of the function MacroManager::LoadMacros we need it to check whether or not the current Macro we're reading isn't missing any keys or values.

If the file is incorrect- correctly assign values to the macro and rewrite the file. Make sure to only mess with values that are unset or not existing.

Setup A User Configuration Folder

Depending upon the users OS we may need to change things up a little bit.

Location of config files in project c++
macos - Application's data folder in mac

We need quick and clean access to all files within this folder. Create a module user_config.h that allows for interaction between these folders. We need a method to return the absolute path to the users config folder. A method named GetConfigFolderPath or alike would be perfect. We want the json module to be easily interfaced with this.

Linux/Unix:

We need to store the data within /etc/pk

Windows:

Within C:Users%USERNAME%AppDataLocal/PrimedKeys

Mac:

Within /Users/USERNAME/Library/Application Support/PrimedKeys

Implement Testing

Make a new folder test which holds a main file called test.h, with a main function RunTests(). That method should then allow for bundling up whatever methods that run tests in their own files inside of this main method.

This method should be run after initialization of the rendering framework.

Show TextureButton Icon On Top

Allow for the loading and displaying of another image file to display on top of the base button. Check images/buttons. Possibly merge these two together within a texture to allow the modification via shader.

Applying a Color Lookup Table to Textures for Custom Palettes

Ideally I would like to use any image from images/palettes to swap out the colors for any widget or texture I'm using at the time. For right now I'm simply using my custom implementation of Dear ImGui's ImageButtonEx() function. We use a special function utilizing a library stb_image.h to load all of our textures. Inside of this function is where we need to allow for the color lookup table to be implemented.

We would replace the colors like so:

image

Ideally I would like this feature to allow for an input of a file path or some way to use any palette you want.
Later on it would be great to allow for more colors in one palette- since we will allow custom textures.

Images Have Black Backgrounds

If you look closely you can see that the images are being drawn with a black background. Not sure why but it's not intended.
image

Differentiating Loaded Textures Based on Applied Shaders

I figured in the future we may run into an issue with our applied shaders if we only return a texture based on the file path, which probably means we should find a way to make the cache allow for multiple textures of the same file based on what shaders are going to be applied.

Platform Specific Handle Window Focus

In order for the macros on the MacroMenu to work correctly, the window focus must never be set to the MacroMenu, otherwise the macros will be run on it. We want the macros to run on the window that is currently focused. If I were on Chrome, and I pressed a button on the MacroMenu that ran the ctrl+w macro- I want the focus to always stay on Chrome, this ensures that the macro will not run on the MacroMenu.

ImTextureID Management Module

Using LoadTextureWithFile every frame is not a good idea, it just floods clones of textures. So we only need to load the texture once.
Ideally move LoadTextureWithFile into namespace tex. We need to keep a map of the currently loaded textures, the keys should be the absolute paths of the files. Then we want the values being of type ImTextureID.

// src/texture.h

namespace tex
{
    // Might have to be reworked in the future due to the usage of the `LoadTextureFromFile` method. 
    // Since we are also going to apply our shader in that method, this might not be a great solution. 
    // We'll have to see later on.
    ImTextureID GetTextureID(std::string file_path[])
    {
        // Check if our map has the file_path
        // If so make sure the texture stored is valid (reload the texture if it is invalid)
        // Return the texture id found in the map.
        // If there is nothing found in the map, load the texture then store it within the map.
    }
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.