├── .gitignore ├── CONTRIBUTING.md ├── LICENSE ├── MakeFile ├── README.md ├── TODO.md ├── docs ├── FAQ.md ├── helpful for dev │ ├── helpful_for_dev.md │ ├── rust_palette.png │ ├── rust_palette_hidden.png │ ├── rust_palette_hidden_zoomed.png │ └── rust_palette_template.png └── tutorial │ └── Capture_Areas.png ├── images ├── RustDaVinci-Preview-1.png ├── RustDaVinci-Preview-2.png ├── RustDaVinci-icon.ico ├── RustDaVinci-logo-1.png └── RustDaVinci-logo-2.png ├── requirements.txt ├── rustdavinci ├── __init__.py ├── app.py ├── app.pyw ├── build_script.py ├── lib │ ├── __init__.py │ ├── captureArea.py │ ├── color_functions.py │ ├── opencv_template │ │ └── rust_palette_template.png │ ├── rustDaVinci.py │ └── rustPaletteData.py ├── opencv_template │ └── rust_palette_template.png ├── pyc ├── test │ ├── alt_quantize_image.py │ ├── identifyColors.py │ └── identify_tool_area.py └── ui │ ├── __init__.py │ ├── dialogs │ ├── __init__.py │ ├── captureDialog.py │ ├── click_color │ │ ├── __init__.py │ │ ├── click_color.py │ │ ├── click_colorui.py │ │ ├── click_colorui.ui │ │ └── convert_ui.py │ └── colors │ │ ├── __init__.py │ │ ├── colors.py │ │ ├── colorsui.py │ │ ├── colorsui.ui │ │ └── convert_ui.py │ ├── resources │ ├── brushes │ │ ├── heavy_round.png │ │ ├── heavy_square.png │ │ ├── light_round.png │ │ └── medium_round.png │ ├── convert_qrc.py │ ├── gifs │ │ ├── capture_canvas.gif │ │ └── capture_ctrl_area.gif │ ├── icons.qrc │ ├── icons │ │ ├── RustDaVinci-icon.ico │ │ ├── RustDaVinci-logo-1.png │ │ ├── RustDaVinci-logo-2.png │ │ ├── load_image_icon.png │ │ ├── paint_image_icon.png │ │ ├── select_area_icon.png │ │ └── settings_icon.png │ └── icons_rc.py │ ├── settings │ ├── __init__.py │ ├── convert_ui.py │ ├── default_settings.py │ ├── settings.py │ ├── settingsui.py │ └── settingsui.ui │ └── views │ ├── __init__.py │ ├── convert_ui.py │ ├── main.py │ ├── mainui.py │ └── mainui.ui ├── screenshots ├── Kirito.jpg ├── MrRobot.jpg ├── RustReference.jpg ├── RustTheShining.jpg ├── RustVikings.jpg ├── Stormtrooper.jpg ├── Troll.jpg └── darthvader.jpg └── setup.py /.gitignore: -------------------------------------------------------------------------------- 1 | # Python 2 | # Byte-compiled / optimized / DLL files 3 | __pycache__/ 4 | *.py[cod] 5 | *$py.class 6 | 7 | # C extensions 8 | *.so 9 | 10 | # Distribution / packaging 11 | .Python 12 | build/ 13 | develop-eggs/ 14 | dist/ 15 | downloads/ 16 | eggs/ 17 | .eggs/ 18 | #lib/ 19 | lib64/ 20 | parts/ 21 | sdist/ 22 | var/ 23 | wheels/ 24 | pip-wheel-metadata/ 25 | share/python-wheels/ 26 | *.egg-info/ 27 | .installed.cfg 28 | *.egg 29 | MANIFEST 30 | 31 | # PyInstaller 32 | # Usually these files are written by a python script from a template 33 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 34 | *.manifest 35 | *.spec 36 | 37 | # Installer logs 38 | pip-log.txt 39 | pip-delete-this-directory.txt 40 | 41 | # Unit test / coverage reports 42 | htmlcov/ 43 | .tox/ 44 | .nox/ 45 | .coverage 46 | .coverage.* 47 | .cache 48 | nosetests.xml 49 | coverage.xml 50 | *.cover 51 | .hypothesis/ 52 | .pytest_cache/ 53 | 54 | # Translations 55 | *.mo 56 | *.pot 57 | 58 | # Django stuff: 59 | *.log 60 | local_settings.py 61 | db.sqlite3 62 | db.sqlite3-journal 63 | 64 | # Flask stuff: 65 | instance/ 66 | .webassets-cache 67 | 68 | # Scrapy stuff: 69 | .scrapy 70 | 71 | # Sphinx documentation 72 | docs/_build/ 73 | 74 | # PyBuilder 75 | target/ 76 | 77 | # Jupyter Notebook 78 | .ipynb_checkpoints 79 | 80 | # IPython 81 | profile_default/ 82 | ipython_config.py 83 | 84 | # pyenv 85 | .python-version 86 | 87 | # pipenv 88 | # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. 89 | # However, in case of collaboration, if having platform-specific dependencies or dependencies 90 | # having no cross-platform support, pipenv may install dependencies that don't work, or not 91 | # install all needed dependencies. 92 | #Pipfile.lock 93 | 94 | # celery beat schedule file 95 | celerybeat-schedule 96 | 97 | # SageMath parsed files 98 | *.sage.py 99 | 100 | # Environments 101 | .env 102 | .venv 103 | env/ 104 | venv/ 105 | ENV/ 106 | env.bak/ 107 | venv.bak/ 108 | 109 | # Spyder project settings 110 | .spyderproject 111 | .spyproject 112 | 113 | # Rope project settings 114 | .ropeproject 115 | 116 | # mkdocs documentation 117 | /site 118 | 119 | # mypy 120 | .mypy_cache/ 121 | .dmypy.json 122 | dmypy.json 123 | 124 | # Pyre type checker 125 | .pyre/ 126 | 127 | 128 | # VIM 129 | # Swap 130 | [._]*.s[a-v][a-z] 131 | [._]*.sw[a-p] 132 | [._]s[a-rt-v][a-z] 133 | [._]ss[a-gi-z] 134 | [._]sw[a-p] 135 | 136 | # Session 137 | Session.vim 138 | Sessionx.vim 139 | 140 | # Temporary 141 | .netrwhist 142 | *~ 143 | # Auto-generated tag files 144 | tags 145 | # Persistent undo 146 | [._]*.un~ 147 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing 2 | 3 | Hello! Interested in contributing to this repository and make RustDaVinci even more awesome? Great! 4 | When contributing to this repository, please first discuss the change you wish to make via email, You can refer to the [TODO list](TODO.md) where most of the tasks, ideas and bugs are located. Testing from the master branch is always appreciated and any issues that is found should be added to the TODO list. 5 | 6 | Please note we have a code of conduct, please follow it in all your interactions with the project. 7 | 8 | ## Recommendation 9 | 10 | When working on/ testing this repository it is highly recommended that you host a private rust server and include "+server.secure 0" in your .bat file. This allow you to avoid trouble with EAC. 11 | 12 | Follow [this guide](https://www.rustafied.com/how-to-host-your-own-rust-server) to create your own Rust Dedicated Server. 13 | 14 | ## Pull Request Process 15 | 16 | 1. Test it! Ensure that your fix does not break the rest of the code. 17 | 2. Update the [TODO list](TODO.md) and possibly the [README file](README.md) with necessary information about the changes you've made. Things such as Changes to the interface, new modules used should update the setup.py and requirements.txt, new files etc... 18 | 3. When you are satisfied with the fix go ahead rebase & squash your commits and create a Pull Request. 19 | 4. Once the Pull Request has been reviewed and accepted, maintainer will merge it into the master branch. 20 | 21 | ## Code of Conduct 22 | 23 | ### Our Pledge 24 | 25 | In the interest of fostering an open and welcoming environment, we as 26 | contributors and maintainers pledge to making participation in our project and 27 | our community a harassment-free experience for everyone, regardless of age, body 28 | size, disability, ethnicity, gender identity and expression, level of experience, 29 | nationality, personal appearance, race, religion, or sexual identity and 30 | orientation. 31 | 32 | ### Our Standards 33 | 34 | Examples of behavior that contributes to creating a positive environment 35 | include: 36 | 37 | * Using welcoming and inclusive language 38 | * Being respectful of differing viewpoints and experiences 39 | * Gracefully accepting constructive criticism 40 | * Focusing on what is best for the community 41 | * Showing empathy towards other community members 42 | 43 | Examples of unacceptable behavior by participants include: 44 | 45 | * The use of sexualized language or imagery and unwelcome sexual attention or 46 | advances 47 | * Trolling, insulting/derogatory comments, and personal or political attacks 48 | * Public or private harassment 49 | * Publishing others' private information, such as a physical or electronic 50 | address, without explicit permission 51 | * Other conduct which could reasonably be considered inappropriate in a 52 | professional setting 53 | 54 | ### Our Responsibilities 55 | 56 | Project maintainers are responsible for clarifying the standards of acceptable 57 | behavior and are expected to take appropriate and fair corrective action in 58 | response to any instances of unacceptable behavior. 59 | 60 | Project maintainers have the right and responsibility to remove, edit, or 61 | reject comments, commits, code, wiki edits, issues, and other contributions 62 | that are not aligned to this Code of Conduct, or to ban temporarily or 63 | permanently any contributor for other behaviors that they deem inappropriate, 64 | threatening, offensive, or harmful. 65 | 66 | ### Scope 67 | 68 | This Code of Conduct applies both within project spaces and in public spaces 69 | when an individual is representing the project or its community. Examples of 70 | representing a project or community include using an official project e-mail 71 | address, posting via an official social media account, or acting as an appointed 72 | representative at an online or offline event. Representation of a project may be 73 | further defined and clarified by project maintainers. 74 | 75 | ### Enforcement 76 | 77 | Instances of abusive, harassing, or otherwise unacceptable behavior may be 78 | reported by contacting the project team at [Alexander.Emanuelsson94@gmail.com]. All 79 | complaints will be reviewed and investigated and will result in a response that 80 | is deemed necessary and appropriate to the circumstances. The project team is 81 | obligated to maintain confidentiality with regard to the reporter of an incident. 82 | Further details of specific enforcement policies may be posted separately. 83 | 84 | Project maintainers who do not follow or enforce the Code of Conduct in good 85 | faith may face temporary or permanent repercussions as determined by other 86 | members of the project's leadership. 87 | 88 | ### Attribution 89 | 90 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, 91 | available at [http://contributor-covenant.org/version/1/4][version] 92 | 93 | [homepage]: http://contributor-covenant.org 94 | [version]: http://contributor-covenant.org/version/1/4/ 95 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | -------------------------------------------------------------------------------- /MakeFile: -------------------------------------------------------------------------------- 1 | develop: 2 | pip install -r requirements.txt 3 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

2 | 3 |

4 | 5 |

6 | discord 7 | reddit 8 | donate on ko-fi 9 | 10 |

RustDaVinci - An automatic sign painter for Rust Facepunch

11 |

12 | 13 | ## **WARNING!** 14 | *This application have not yet been approved by Facepunch nor EAC. According to Facepunch, the only way for the application to get white-listed with EAC is to publish it on steam. Publishing it on steam comes with a fee of 100$ which I'm not prepared to pay. With this said, I leave the application/ code free and open-source for anyone that is interested to see how I did or potentially contribute.* 15 | 16 | ## Video demonstration 17 | 18 | ### **https://www.youtube.com/watch?v=QArgjwmhP_Y** 19 | 20 | ## Features 21 | 22 | NOTE: Only tested on Windows 10 23 | 24 | * Support for image formats .png, .jpg, .jpeg, .gif 25 | * Import local image or provide URL to image on the internet 26 | * Set pixel perfect location of the paint controls area 27 | * Choose which colors to skip in the painting process 28 | * Setting for utilizing the "hidden colors" which in total paints using 256 possible colors 29 | * Wide variety of settings to allow modification of quality, painting algorithm and used colors 30 | * Setting for drawing lines if calculated to be faster 31 | * Automatically update the canvas whilst painting 32 | * Unlimited painting time 33 | * Automatically paint the background with the background color defined in settings 34 | * Play around with settings such as mouse-click delay, line-draw delay, color changing delay and minimum line width to optimize the speed and accuracy of the painting process. 35 | 36 | ## How it works 37 | 38 | 1. Click the "Load Image..." button and select an image from disk or URL 39 | 2. Click the "Show Image >>" button to get a preview of how the canvas will look when the painting process is done. There are three buttons when the preview is shown, "Original" which shows the original image, "Normal" that shows the normal quality outcome and "High" which shows the outcome of the high quality dithering algorithm. 40 | 3. You can also open settings while the preview is shown to modify things such as "Use the hidden colors palette" and "Improve paintings by utilizing different brush opacities" and immediately see the impact on the preview. 41 | 4. When you are satisfied with the settings you can go ahead and click the button "Capture Control Area". This will give you two alternatives, either capture it manually (shown in the gifs below), or capture it automatically using openCV. 42 | 5. When the paint control area is captured you can go ahead and click the "Paint Image". This will prompt you to capture the area in which the canvas is located. It's the same procedure as with manually capturing the paint controls area. After that, RustDaVinci will calculate things such as estimated time, amount of pixels to paint, lines to paint, dimensions of the canvas and finaly give you the option to start painting. 43 | 6. While RustDaVinci is painting it is recommended to not move the mouse nor keyboard. You can follow the progress both from the progressbar and also the output window which shows what colors it's on. During the painting process, it is possible to cancel the painting process (default ESC), pause the painting process (default F10) or skip the current color (default F11). 44 | 45 | 46 | ![Capture Canvas](rustdavinci/ui/resources/gifs/capture_canvas.gif) 47 | 48 | ![Capture Paint Control Area](rustdavinci/ui/resources/gifs/capture_ctrl_area.gif) 49 | 50 | 51 | ## Setting up for contribution 52 | Make sure you read the [CONTRIBUTING.md](CONTRIBUTING.md) file to setup a dedicated rust server. 53 | 54 | Clone the repository with the following command: 55 | 56 | ``` bash 57 | git clone https://github.com/alexemanuelol/RustDaVinci.git 58 | ``` 59 | 60 | Enter the repository and run the following command to install python modules 61 | 62 | ``` bash 63 | pip3 install -r requirements.txt 64 | ``` 65 | 66 | ## Screenshots 67 | 68 | ![RustDaVinci Preview Image 1](images/RustDaVinci-Preview-1.png) 69 | 70 | ![RustDaVinci Preview Image 2](images/RustDaVinci-Preview-2.png) 71 | 72 | ![darth vader](screenshots/darthvader.jpg) 73 | 74 | ![Kirito](screenshots/Kirito.jpg) 75 | 76 | ![Mr Robot](screenshots/MrRobot.jpg) 77 | 78 | ![Rust Reference](screenshots/RustReference.jpg) 79 | 80 | ![Rust The Shining](screenshots/RustTheShining.jpg) 81 | 82 | ![RustVikings](screenshots/RustVikings.jpg) 83 | 84 | ![Stormtrooper](screenshots/Stormtrooper.jpg) 85 | 86 | ![Troll](screenshots/Troll.jpg) 87 | -------------------------------------------------------------------------------- /TODO.md: -------------------------------------------------------------------------------- 1 | # TODO 2 | 3 | ## Coding 4 | - Setup CI travis yml (When repo public) 5 | - Create a script that gather all coordinates for all different colors in the palette 6 | 7 | 8 | ## Testing 9 | 10 | 11 | ## Other 12 | - Get Facepunch and EAC to recognize this application and what it is capable of doing. Contact them. 13 | - Create a howto/ tutorial guide. 14 | - Add more to FAQ 15 | - Expand README file, youtube video, features, general information about the application and the author 16 | 17 | 18 | # Potentially big todos 19 | - Try to lower the calculation time for statistics. At the moment it is very long... 20 | 21 | 22 | # Known errors 23 | -------------------------------------------------------------------------------- /docs/FAQ.md: -------------------------------------------------------------------------------- 1 | ## Frequently Asked Questions about the RustDaVinci application 2 | 3 | **Q: Why is there white dots/ lines in my painting?** 4 | 5 | **A:** This happens because there is a mismatch between the image ratio and the in-game frame ratio. Let's say you've captured an area that is 256x256 and covers the entire frame, and the in-game frame is 512x512, which means RustDaVinci will only paint 256 of a total of 512 in-game frame pixels. The issue can be solved by zooming in the frame a bit before capturing the painting area, i.e. trying to sync the ratios. NOTE: The larger the captured area is, the longer the painting time will be. 6 | 7 | ## 8 | 9 | **Q: ** 10 | 11 | **A:** 12 | 13 | ## 14 | 15 | **Q: ** 16 | 17 | **A:** 18 | 19 | ## 20 | 21 | **Q: ** 22 | 23 | **A:** 24 | 25 | ## 26 | 27 | **Q: ** 28 | 29 | **A:** 30 | 31 | ## 32 | 33 | **Q: ** 34 | 35 | **A:** 36 | 37 | ## 38 | 39 | **Q: ** 40 | 41 | **A:** 42 | 43 | ## 44 | 45 | **Q: ** 46 | 47 | **A:** 48 | 49 | ## 50 | -------------------------------------------------------------------------------- /docs/helpful for dev/helpful_for_dev.md: -------------------------------------------------------------------------------- 1 | # Helpful things for the project: 2 | 3 | ## Generate quantized images 4 | 5 | ### ./src/test/alt_quantize_image.py 6 | Perhaps a middle quality quantize.. cons - it is very slow in generating the image 7 | 8 | 9 | ## The hidden palette 10 | 11 | - Useful site: https://imgur.com/a/L7P0f 12 | 13 | ### ./src/test/identifyColors.py 14 | Script that print out every single pixel from the palette onto a picture frame in-game. 15 | NOTE: The coordinates needs to be modified to the correct placement of the control area. 16 | 17 | ![Demonstration of the what the script accomplishes](rust_palette_hidden.png) 18 | 19 | 20 | ## Identify control area automatically with opencv 21 | 22 | ### ./src/test/identify_tool_area.py 23 | Script uses opencv to take a screenshot and look for the template to match somewhere (rust_palette_template.png). 24 | 25 | ![The template for the control area](rust_palette_template.png) 26 | 27 | ## Test GUI 28 | 29 | ### ./src/test/testGUI.py 30 | Testing for python gui pyqt5 31 | 32 | 33 | ## Useful articles and links: 34 | 35 | ### Dithering image/ quantize 36 | https://stackoverflow.com/questions/53477624/python-pil-image-convert-not-replacing-color-with-the-closest-palette 37 | https://stackoverflow.com/questions/29433243/convert-image-to-specific-palette-using-pil-without-dithering 38 | https://stackoverflow.com/questions/236692/how-do-i-convert-any-image-to-a-4-color-paletted-image-using-the-python-imaging-l 39 | 40 | ### Function for getting "primary" color for an image with defined palette 41 | https://www.codementor.io/isaib.cicourel/image-manipulation-in-python-du1089j1u 42 | -------------------------------------------------------------------------------- /docs/helpful for dev/rust_palette.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alexemanuelol/rustdavinci/89c749f78b4922383acc70b503e1e68a50c02f5f/docs/helpful for dev/rust_palette.png -------------------------------------------------------------------------------- /docs/helpful for dev/rust_palette_hidden.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alexemanuelol/rustdavinci/89c749f78b4922383acc70b503e1e68a50c02f5f/docs/helpful for dev/rust_palette_hidden.png -------------------------------------------------------------------------------- /docs/helpful for dev/rust_palette_hidden_zoomed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alexemanuelol/rustdavinci/89c749f78b4922383acc70b503e1e68a50c02f5f/docs/helpful for dev/rust_palette_hidden_zoomed.png -------------------------------------------------------------------------------- /docs/helpful for dev/rust_palette_template.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alexemanuelol/rustdavinci/89c749f78b4922383acc70b503e1e68a50c02f5f/docs/helpful for dev/rust_palette_template.png -------------------------------------------------------------------------------- /docs/tutorial/Capture_Areas.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alexemanuelol/rustdavinci/89c749f78b4922383acc70b503e1e68a50c02f5f/docs/tutorial/Capture_Areas.png -------------------------------------------------------------------------------- /images/RustDaVinci-Preview-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alexemanuelol/rustdavinci/89c749f78b4922383acc70b503e1e68a50c02f5f/images/RustDaVinci-Preview-1.png -------------------------------------------------------------------------------- /images/RustDaVinci-Preview-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alexemanuelol/rustdavinci/89c749f78b4922383acc70b503e1e68a50c02f5f/images/RustDaVinci-Preview-2.png -------------------------------------------------------------------------------- /images/RustDaVinci-icon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alexemanuelol/rustdavinci/89c749f78b4922383acc70b503e1e68a50c02f5f/images/RustDaVinci-icon.ico -------------------------------------------------------------------------------- /images/RustDaVinci-logo-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alexemanuelol/rustdavinci/89c749f78b4922383acc70b503e1e68a50c02f5f/images/RustDaVinci-logo-1.png -------------------------------------------------------------------------------- /images/RustDaVinci-logo-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alexemanuelol/rustdavinci/89c749f78b4922383acc70b503e1e68a50c02f5f/images/RustDaVinci-logo-2.png -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | Pillow==8.3.2 2 | PyAutoGUI==0.9.41 3 | pypiwin32==223 4 | colorama==0.4.1 5 | termcolor==1.1.0 6 | pynput==1.4.2 7 | numpy==1.16.2 8 | opencv-python==4.0.0.21 9 | pyqt5-tools==5.13.0.1.5 10 | PyQt5==5.13.1 11 | -------------------------------------------------------------------------------- /rustdavinci/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alexemanuelol/rustdavinci/89c749f78b4922383acc70b503e1e68a50c02f5f/rustdavinci/__init__.py -------------------------------------------------------------------------------- /rustdavinci/app.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | 4 | from PyQt5 import QtCore 5 | from PyQt5 import QtWidgets 6 | 7 | import sys 8 | 9 | from ui.views.main import MainWindow 10 | 11 | 12 | def run(): 13 | 14 | # Set some application settings for QSettings 15 | QtCore.QCoreApplication.setOrganizationName("RustDaVinci") 16 | QtCore.QCoreApplication.setApplicationName("RustDaVinci") 17 | 18 | # Setup the application and start 19 | app = QtWidgets.QApplication(sys.argv) 20 | 21 | main = MainWindow() 22 | main.show() 23 | sys.exit(app.exec_()) 24 | 25 | 26 | if __name__ == "__main__": 27 | run() 28 | -------------------------------------------------------------------------------- /rustdavinci/app.pyw: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | 4 | from PyQt5 import QtCore 5 | from PyQt5 import QtWidgets 6 | 7 | import sys 8 | 9 | from ui.views.main import MainWindow 10 | 11 | 12 | def run(): 13 | 14 | # Set some application settings for QSettings 15 | QtCore.QCoreApplication.setOrganizationName("RustDaVinci") 16 | QtCore.QCoreApplication.setApplicationName("RustDaVinci") 17 | 18 | # Setup the application and start 19 | app = QtWidgets.QApplication(sys.argv) 20 | 21 | main = MainWindow() 22 | main.show() 23 | sys.exit(app.exec_()) 24 | 25 | 26 | if __name__ == "__main__": 27 | run() 28 | -------------------------------------------------------------------------------- /rustdavinci/build_script.py: -------------------------------------------------------------------------------- 1 | import subprocess 2 | import os 3 | import shutil 4 | import glob 5 | 6 | # Requires pyinstaller 7 | 8 | 9 | def remove_content(folder_path): 10 | """ Remove content of a fiven folder """ 11 | for f in os.listdir(folder_path): 12 | file_path = os.path.join(folder_path, f) 13 | try: 14 | if os.path.isfile(file_path) or os.path.islink(file_path): 15 | os.unlink(file_path) 16 | elif os.path.isdir(file_path): 17 | shutil.rmtree(file_path) 18 | except Exception as e: 19 | print('Failed to delete %s. Reason: %s' % (file_path, e)) 20 | 21 | 22 | def copy_content(src, dst, symlinks=False, ignore=None): 23 | """ Copy content of a given folder to a destination folder """ 24 | for item in os.listdir(src): 25 | s = os.path.join(src, item) 26 | d = os.path.join(dst, item) 27 | if os.path.isdir(s): 28 | shutil.copytree(s, d, symlinks, ignore) 29 | else: 30 | shutil.copy2(s, d) 31 | 32 | 33 | def move_content(srcDir, dstDir): 34 | """ Move content from a given folder to a destination folder """ 35 | for filePath in glob.glob(srcDir + '\*'): 36 | shutil.move(filePath, dstDir); 37 | 38 | 39 | def main(): 40 | # Build with pyinstaller 41 | subprocess.run('pyinstaller --name="RustDaVinci" --icon=./../images/RustDaVinci-icon.ico app.pyw') 42 | 43 | # Create executable folder if not exist, else remove content of executable folder 44 | folder_name = "executable" 45 | if not os.path.exists(folder_name): 46 | os.makedirs(folder_name) 47 | else: 48 | remove_content(folder_name) 49 | 50 | # move build from dist to executable folder 51 | move_content("dist/", folder_name) 52 | 53 | # move opencv_template folder to executable folder 54 | os.mkdir("executable/RustDaVinci/opencv_template") 55 | copy_content("opencv_template/", "executable/RustDaVinci/opencv_template/") 56 | 57 | # Remove build directories 58 | remove_content("build/") 59 | os.rmdir("build") 60 | os.rmdir("dist") 61 | os.remove("RustDaVinci.spec") 62 | 63 | 64 | 65 | if __name__ == "__main__": 66 | main() 67 | -------------------------------------------------------------------------------- /rustdavinci/lib/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alexemanuelol/rustdavinci/89c749f78b4922383acc70b503e1e68a50c02f5f/rustdavinci/lib/__init__.py -------------------------------------------------------------------------------- /rustdavinci/lib/captureArea.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | 4 | from pynput import keyboard 5 | 6 | import tkinter 7 | import pyautogui 8 | import win32api 9 | import time 10 | 11 | abort_capturing_mode = False 12 | 13 | 14 | def key_event(key): 15 | """ Abort capturing mode """ 16 | global abort_capturing_mode 17 | abort_capturing_mode = True 18 | 19 | 20 | def capture_area(): 21 | """ Capture an area on the screen by clicking and dragging the mouse to the bottom right corner. 22 | Returns: area_x, 23 | area_y, 24 | area_width, 25 | area_height 26 | """ 27 | global abort_capturing_mode 28 | listener = keyboard.Listener(on_press=key_event) 29 | listener.start() 30 | 31 | root = tkinter.Tk().withdraw() 32 | area = tkinter.Toplevel(root) 33 | area.overrideredirect(1) 34 | area.wm_attributes('-alpha',0.5) 35 | area.geometry("0x0") 36 | 37 | prev_state = win32api.GetKeyState(0x01) 38 | pressed, active = False, False 39 | 40 | while True: 41 | if abort_capturing_mode: 42 | abort_capturing_mode = False 43 | listener.stop() 44 | return False 45 | 46 | current_state = win32api.GetKeyState(0x01) 47 | mouse = pyautogui.position() 48 | 49 | if current_state != prev_state: 50 | prev_state = current_state 51 | pressed = True if current_state < 0 else False 52 | 53 | try: 54 | if pressed: 55 | if not active: 56 | area_TL = mouse 57 | active = True 58 | area.geometry(str(mouse[0] - area_TL[0])+ "x" + str(mouse[1] - area_TL[1])) 59 | elif not pressed: 60 | if active: 61 | area.destroy() 62 | if area_TL[0] >= mouse[0] or area_TL[1] >= mouse[1]: 63 | listener.stop() 64 | return 0, 0, 0, 0 65 | listener.stop() 66 | return area_TL[0], area_TL[1], mouse[0] - area_TL[0], mouse[1] - area_TL[1] 67 | area.geometry("+" + str(mouse[0])+ "+" + str(mouse[1])) 68 | 69 | except Exception: pass 70 | 71 | area.update_idletasks() 72 | area.update() 73 | 74 | 75 | def show_area(x, y, w, h): 76 | """ Set a grey box at the coordinates """ 77 | global abort_capturing_mode 78 | listener = keyboard.Listener(on_press=key_event) 79 | listener.start() 80 | 81 | root = tkinter.Tk().withdraw() 82 | area = tkinter.Toplevel(root) 83 | area.overrideredirect(1) 84 | area.wm_attributes('-alpha',0.5) 85 | area.geometry("0x0") 86 | 87 | area.geometry("%dx%d+%d+%d" % (w, h, x, y)) 88 | 89 | area.update_idletasks() 90 | area.update() 91 | 92 | time.sleep(3) 93 | 94 | area.destroy() -------------------------------------------------------------------------------- /rustdavinci/lib/color_functions.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | 4 | from math import sqrt 5 | 6 | from lib.rustPaletteData import rust_palette 7 | 8 | 9 | def hex_to_rgb(hex): 10 | """ Convert hexadecimal color to rgb """ 11 | h = hex.lstrip("#") 12 | rgb = tuple(int(h[i:i+2], 16) for i in (0, 2, 4)) 13 | return rgb 14 | 15 | 16 | def rgb_to_hex(rgb): 17 | """ Convert rgb to hexadecimal color """ 18 | return ("#%02x%02x%02x" % rgb).upper() 19 | 20 | 21 | def closest_color(rgb): 22 | """ Find the closest color from the rust_palette file """ 23 | r, g, b = rgb 24 | color_diffs = [] 25 | for color in rust_palette: 26 | cr, cg, cb = color 27 | color_diff = sqrt(abs(r - cr)**2 + abs(g - cg)**2 + abs(b - cb)**2) 28 | color_diffs.append((color_diff, color)) 29 | return min(color_diffs)[1] 30 | -------------------------------------------------------------------------------- /rustdavinci/lib/opencv_template/rust_palette_template.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alexemanuelol/rustdavinci/89c749f78b4922383acc70b503e1e68a50c02f5f/rustdavinci/lib/opencv_template/rust_palette_template.png -------------------------------------------------------------------------------- /rustdavinci/lib/rustPaletteData.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | 4 | rust_palette = [ 5 | ### First opacity ### 6 | # Visable colors 7 | (46, 204, 113), (46, 157, 135), (39, 174, 96), (22, 160, 133), (29, 224, 25), 8 | (52, 152, 218), (32, 203, 241), (74, 212, 189), (126, 76, 42), (68, 48, 34), 9 | (241, 195, 15), (175, 122, 195), (240, 67, 49), (142, 68, 173), (230, 126, 34), 10 | (152, 163, 163), (236, 240, 241), (49, 49, 49), (52, 73, 94), (2, 2, 2), 11 | 12 | # Hidden colors 13 | (255, 230, 212), (254, 255, 208), (255, 187, 142), (214, 252, 165), (164, 255, 255), 14 | (214, 139, 255), (255, 166, 166), (79, 79, 225), (101, 255, 255), (237, 66, 255), 15 | (64, 91, 178), (13, 132, 227), (255, 79, 79), (13, 91, 145), (22, 240, 241), 16 | (42, 22, 232), (143, 13, 254), (210, 22, 243), (220, 13, 71), (237, 0, 0), 17 | (142, 34, 28), (251, 108, 13), (177, 229, 22), (184, 73, 0), (161, 184, 0), 18 | (71, 190, 0), (119, 56, 13), (246, 160, 22), (93, 106, 0), (13, 101, 0), 19 | (42, 115, 114), (0, 0, 88), (56, 0, 88), (106, 0, 0), (42, 13, 0), 20 | (42, 46, 0), (42, 0, 46), (34, 0, 0), (0, 13, 0), (53, 73, 95), 21 | (0, 0, 13), (126, 75, 42), (83, 118, 118), (53, 71, 126), 22 | 23 | ### Second opacity ### 24 | # Visable colors 25 | (91, 175, 118), (91, 144, 130), (89, 155, 109), (91, 148, 132), (87, 189, 86), 26 | (93, 141, 185), (88, 174, 201), (99, 180, 164), (125, 100, 90), (98, 92, 88), 27 | (202, 171, 90), (157, 126, 171), (202, 101, 96), (137, 102, 156), (195, 128, 93), 28 | (143, 150, 150), (197, 200, 201), (92, 92, 92), (93, 100, 109), (84, 84, 84), 29 | 30 | # Hidden colors 31 | (211, 194, 181), (212, 212, 179), (211, 164, 135), (182, 209, 149), (148, 211, 210), 32 | (183, 136, 212), (212, 152, 152), (106, 106, 191), (115, 212, 212), (200, 101, 212), 33 | (100, 111, 160), (90, 132, 193), (211, 103, 103), (87, 109, 138), (82, 199, 199), 34 | (94, 91, 196), (138, 90, 212), (179, 85, 202), (186, 88, 100), (200, 89, 89), 35 | (137, 93, 92), (207, 115, 84), (156, 192, 85), (163, 102, 87), (149, 163, 89), 36 | (103, 168, 89), (124, 98, 90), (206, 148, 91), (112, 118, 89), (90, 115, 89), 37 | (94, 122, 122), (87, 87, 108), (98, 89, 110), (120, 89, 89), (94, 90, 89), 38 | (94, 95, 89), (92, 87, 93), (93, 89, 89), (89, 90, 89), (93, 96, 96), 39 | (86, 87, 87), (125, 97, 85), (107, 124, 124), (97, 103, 128), 40 | 41 | 42 | ### Third opacity ### 43 | # Visable colors 44 | (111, 149, 121), (117, 138, 132), (116, 143, 123), (109, 134, 126), (110, 157, 109), 45 | (111, 132, 155), (110, 149, 163), (114, 152, 144), (125, 114, 111), (113, 111, 110), 46 | (163, 146, 109), (139, 123, 146), (155, 102, 99), (129, 113, 138), (159, 125, 110), 47 | (137, 140, 140), (162, 163, 163), (111, 111, 111), (111, 114, 118), (109, 109, 109), 48 | 49 | # Hidden colors 50 | (173, 163, 156), (173, 173, 155), (173, 147, 134), (157, 172, 140), (140, 173, 173), 51 | (157, 133, 173), (173, 141, 141), (117, 117, 159), (124, 173, 173), (163, 116, 171), 52 | (119, 123, 144), (115, 131, 162), (173, 121, 121), (115, 123, 135), (112, 165, 165), 53 | (117, 115, 164), (134, 115, 173), (154, 113, 166), (159, 115, 120), (166, 115, 115), 54 | (134, 116, 116), (171, 126, 115), (139, 159, 109), (146, 120, 115), (135, 143, 110), 55 | (120, 148, 115), (128, 118, 115), (169, 139, 115), (123, 125, 115), (110, 120, 110), 56 | (111, 122, 122), (115, 115, 122), (118, 115, 122), (120, 106, 108), (117, 115, 115), 57 | (117, 117, 115), (117, 115, 117), (116, 115, 115), (115, 115, 115), (116, 117, 117), 58 | (112, 112, 112), (131, 120, 116), (121, 128, 128), (117, 120, 130), 59 | 60 | 61 | ### Fourth opacity ### 62 | # Visable colors 63 | (126, 140, 129), (119, 127, 125), (126, 136, 128), (125, 134, 131), (126, 143, 125), 64 | (120, 127, 136), (126, 139, 146), (127, 141, 138), (124, 120, 119), (120, 119, 119), 65 | (146, 139, 125), (136, 130, 139), (145, 127, 126), (132, 127, 135), (138, 124, 119), 66 | (127, 128, 128), (145, 145, 146), (119, 119, 119), (126, 127, 128), (119, 119, 119), 67 | 68 | # Hidden colors 69 | (148, 144, 141), (148, 148, 140), (148, 137, 132), (141, 148, 134), (134, 148, 148), 70 | (141, 132, 148), (148, 135, 135), (124, 124, 140), (125, 145, 145), (145, 127, 148), 71 | (123, 124, 133), (125, 131, 143), (148, 127, 127), (125, 127, 132), (125, 145, 146), 72 | (126, 125, 144), (132, 125, 148), (140, 125, 146), (140, 123, 124), (145, 125, 125), 73 | (132, 126, 126), (147, 129, 125), (136, 144, 125), (137, 127, 125), (129, 132, 120), 74 | (127, 138, 125), (129, 126, 125), (146, 134, 125), (128, 129, 125), (125, 128, 125), 75 | (126, 129, 129), (121, 121, 124), (126, 125, 128), (129, 125, 125), (126, 125, 125), 76 | (126, 126, 125), (126, 125, 126), (123, 123, 123), (125, 125, 125), (123, 123, 123), 77 | (125, 125, 125), (131, 127, 126), (128, 130, 130), (126, 127, 130) 78 | ] 79 | -------------------------------------------------------------------------------- /rustdavinci/opencv_template/rust_palette_template.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alexemanuelol/rustdavinci/89c749f78b4922383acc70b503e1e68a50c02f5f/rustdavinci/opencv_template/rust_palette_template.png -------------------------------------------------------------------------------- /rustdavinci/pyc: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Delete Python's compiled *.pyc and __pycache__ files recursively in the current directory 4 | 5 | if [ "$1" ]; then 6 | WHERE="$1" 7 | else 8 | WHERE="$PWD" 9 | fi 10 | 11 | find "$WHERE" \ 12 | -name '__pycache__' -delete -print \ 13 | -o \ 14 | -name '*.pyc' -delete -print 15 | -------------------------------------------------------------------------------- /rustdavinci/test/alt_quantize_image.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | # pip install scikit-image 4 | # pip install scipy 5 | 6 | import numpy as np 7 | from PIL import Image 8 | from skimage import color 9 | 10 | def CIE76DeltaE2(Lab1,Lab2): 11 | """Returns the square of the CIE76 Delta-E colour distance between 2 lab colours""" 12 | return (Lab2[0]-Lab1[0])*(Lab2[0]-Lab1[0]) + (Lab2[1]-Lab1[1])*(Lab2[1]-Lab1[1]) + (Lab2[2]-Lab1[2])*(Lab2[2]-Lab1[2]) 13 | 14 | def NearestPaletteIndex(Lab,palLab): 15 | """Return index of entry in palette that is nearest the given colour""" 16 | NearestIndex = 0 17 | NearestDist = CIE76DeltaE2(Lab,palLab[0,0]) 18 | for e in range(1,palLab.shape[0]): 19 | dist = CIE76DeltaE2(Lab,palLab[e,0]) 20 | if dist < NearestDist: 21 | NearestDist = dist 22 | NearestIndex = e 23 | return NearestIndex 24 | 25 | palette = ( 26 | 46, 204, 113, 46, 157, 135, 39, 174, 96, 22, 160, 133, 29, 224, 25, 27 | 52, 152, 218, 32, 203, 241, 74, 212, 189, 126, 76, 42, 68, 48, 34, 28 | 241, 195, 15, 175, 122, 195, 240, 67, 49, 142, 68, 173, 230, 126, 34, 29 | 152, 163, 163, 236, 240, 241, 49, 49, 49, 52, 73, 94, 2, 2, 2, 30 | 31 | 91, 175, 118, 91, 144, 130, 89, 155, 109, 91, 148, 132, 87, 189, 86, 32 | 93, 141, 185, 88, 174, 201, 99, 180, 164, 125, 100, 90, 98, 92, 88, 33 | 202, 171, 90, 157, 126, 171, 202, 101, 96, 137, 102, 156, 195, 128, 93, 34 | 143, 150, 150, 197, 200, 201, 92, 92, 92, 93, 100, 109, 84, 84, 84, 35 | 36 | 111, 149, 121, 117, 138, 132, 116, 143, 123, 109, 134, 126, 110, 157, 109, 37 | 111, 132, 155, 110, 149, 163, 114, 152, 144, 125, 114, 111, 113, 111, 110, 38 | 163, 146, 109, 139, 123, 146, 155, 102, 99, 129, 113, 138, 159, 125, 110, 39 | 137, 140, 140, 162, 163, 163, 111, 111, 111, 111, 114, 118, 109, 109, 109, 40 | 41 | 126, 140, 129, 119, 127, 125, 126, 136, 128, 125, 134, 131, 126, 143, 125, 42 | 120, 127, 136, 126, 139, 146, 127, 141, 138, 124, 120, 119, 120, 119, 119, 43 | 146, 139, 125, 136, 130, 139, 145, 127, 126, 132, 127, 135, 138, 124, 119, 44 | 127, 128, 128, 145, 145, 146, 119, 119, 119, 126, 127, 128, 119, 119, 119 45 | ) + (2, 2, 2) * 176 46 | 47 | # Load the source image as numpy array and convert to Lab colorspace 48 | imnp = np.array(Image.open('C:\\Users\\Alexander\\Downloads\\aaa.png').convert('RGB')) 49 | imLab = color.rgb2lab(imnp) 50 | h,w = imLab.shape[:2] 51 | 52 | # Load palette as numpy array, truncate unused palette entries, and convert to Lab colourspace 53 | palnp = np.array(palette,dtype=np.uint8).reshape(256,1,3)[:80,:] 54 | palLab = color.rgb2lab(palnp) 55 | 56 | # Make numpy array for output image 57 | resnp = np.empty((h,w), dtype=np.uint8) 58 | 59 | # Iterate over pixels, replacing each with the nearest palette entry 60 | for y in range(0, h): 61 | for x in range(0, w): 62 | resnp[y, x] = NearestPaletteIndex(imLab[y,x], palLab) 63 | 64 | # Create output image from indices, whack a palette in and save 65 | resim = Image.fromarray(resnp, mode='P') 66 | resim.putpalette(palette) 67 | #resim.save('result.png') 68 | resim.show() 69 | -------------------------------------------------------------------------------- /rustdavinci/test/identifyColors.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | import pyautogui 4 | import PIL.ImageGrab 5 | import time 6 | import os 7 | 8 | 9 | def main(): 10 | pyautogui.PAUSE = 0.02 11 | 12 | tool_area_TL = (1474, 175) 13 | tool_area_BR = (1674, 751) 14 | 15 | paint_area_TL = (926, 295) 16 | 17 | tool_area_width = tool_area_BR[0] - tool_area_TL[0] 18 | tool_area_height = tool_area_BR[1] - tool_area_TL[1] 19 | 20 | print("Width = " + str(tool_area_width)) 21 | print("Height = " + str(tool_area_height)) 22 | 23 | color_array = [] 24 | 25 | pyautogui.screenshot("rust_palette.png", region=(1474, 390, 200, 361)) 26 | pyautogui.screenshot("rust_palette_hidden.png", region=(926, 295, 200, 361)) 27 | exit() 28 | 29 | for y in range(tool_area_height): 30 | for x in range(tool_area_width): 31 | pyautogui.click(tool_area_TL[0] + x, tool_area_TL[1] + y + 215) 32 | pyautogui.click(paint_area_TL[0] + x, paint_area_TL[1] + y) 33 | #current = PIL.ImageGrab.grab().load()[1376, 974] 34 | #if current not in color_array: 35 | # color_array.append(current) 36 | # print(current) 37 | #time.sleep(.1) 38 | 39 | 40 | if __name__ == "__main__": 41 | main() 42 | -------------------------------------------------------------------------------- /rustdavinci/test/identify_tool_area.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | import cv2 4 | import numpy as np 5 | import pyautogui 6 | import time 7 | 8 | 9 | def locate_palette(): 10 | image_screenshot = pyautogui.screenshot() 11 | screen_width, screen_height = image_screenshot.size 12 | 13 | image_gray = cv2.cvtColor(np.array(image_screenshot), cv2.COLOR_BGR2GRAY) 14 | 15 | template = cv2.imread("rust_palette_template.png", 0) 16 | template_width, template_height = template.shape[::-1] 17 | 18 | x_coordinate, y_coordinate = 0, 0 19 | threshold = 0.8 20 | 21 | for loop in range(50): 22 | matches = cv2.matchTemplate(image_gray, template, cv2.TM_CCOEFF_NORMED) 23 | loc = np.where(matches >= threshold) 24 | 25 | x_list, y_list = [], [] 26 | for point in zip(*loc[::-1]): 27 | x_list.append(point[0]) 28 | y_list.append(point[1]) 29 | 30 | if x_list: 31 | x_coordinate = int(sum(x_list) / len(x_list)) 32 | y_coordinate = int(sum(y_list) / len(y_list)) 33 | return x_coordinate, y_coordinate, template_width, template_height 34 | 35 | template_width, template_height = int(template.shape[1]*1.035), int(template.shape[0]*1.035) 36 | template = cv2.resize(template, (int(template_width), int(template_height))) 37 | 38 | if template_width > screen_width or template_height > screen_height or loop == 49: 39 | print("No match was found...") 40 | return False 41 | 42 | 43 | 44 | if __name__ == "__main__": 45 | tool_area = locate_palette() 46 | 47 | if tool_area is not False: 48 | tool_area_TL = (tool_area[0], tool_area[1]) 49 | tool_area_width = tool_area[2] 50 | tool_area_height = tool_area[3] 51 | 52 | print(tool_area_TL) 53 | print("width = " + str(tool_area_width)) 54 | print("height = " + str(tool_area_height)) 55 | 56 | pyautogui.moveTo(tool_area_TL) 57 | time.sleep(3) 58 | pyautogui.moveTo(tool_area_TL[0] + tool_area_width, tool_area_TL[1] + tool_area_height) 59 | 60 | 61 | 62 | # Youtube video 63 | #https://www.youtube.com/watch?v=2CZltXv-Gpk 64 | -------------------------------------------------------------------------------- /rustdavinci/ui/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alexemanuelol/rustdavinci/89c749f78b4922383acc70b503e1e68a50c02f5f/rustdavinci/ui/__init__.py -------------------------------------------------------------------------------- /rustdavinci/ui/dialogs/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alexemanuelol/rustdavinci/89c749f78b4922383acc70b503e1e68a50c02f5f/rustdavinci/ui/dialogs/__init__.py -------------------------------------------------------------------------------- /rustdavinci/ui/dialogs/captureDialog.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | 4 | from PyQt5.QtCore import QSize 5 | from PyQt5.QtGui import QMovie, QPainter, QFont 6 | from PyQt5.QtWidgets import QDialog, QLabel, QPushButton 7 | 8 | 9 | class CaptureAreaDialog(QDialog): 10 | 11 | def __init__(self, parent=None, dialog=0): 12 | """ init CaptureAreaDialog module """ 13 | super(CaptureAreaDialog, self).__init__(parent) 14 | self.setModal(True) 15 | self.resize(QSize(600, 430)) 16 | self.setFixedSize(QSize(600, 430)) 17 | 18 | self.label = QLabel(self) 19 | self.label.setWordWrap(True) 20 | self.label.setFont(QFont("MS Shell Dlg 2", 10, QFont.Bold)) 21 | self.label.setGeometry(20, 357, 390, 53) 22 | 23 | if dialog == 0: 24 | self.label.setText( "Manually capture the area by drag & drop the top left " + 25 | "corner of the canvas to the bottom right corner.") 26 | self.movie = QMovie(":/gifs/capture_canvas.gif") 27 | else: 28 | self.label.setText( "Manually capture the area by drag & drop the top left " + 29 | "corner of the painting controls area to the bottom right corner.") 30 | self.movie = QMovie(":/gifs/capture_ctrl_area.gif") 31 | 32 | self.movie.frameChanged.connect(self.repaint) 33 | self.movie.start() 34 | 35 | self.ok_button = QPushButton(self) 36 | self.ok_button.setText("OK") 37 | self.ok_button.setGeometry(430, 357, 150, 53) 38 | self.ok_button.clicked.connect(self.ok_clicked) 39 | 40 | 41 | def paintEvent(self, event): 42 | """ Update the gif """ 43 | currentFrame = self.movie.currentPixmap() 44 | frameRect = currentFrame.rect() 45 | if frameRect.intersects(event.rect()): 46 | painter = QPainter(self) 47 | painter.drawPixmap(frameRect.left(), frameRect.top(), currentFrame) 48 | 49 | 50 | def ok_clicked(self): 51 | """ Ok has been clicked, return 1 """ 52 | self.done(1) 53 | -------------------------------------------------------------------------------- /rustdavinci/ui/dialogs/click_color/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alexemanuelol/rustdavinci/89c749f78b4922383acc70b503e1e68a50c02f5f/rustdavinci/ui/dialogs/click_color/__init__.py -------------------------------------------------------------------------------- /rustdavinci/ui/dialogs/click_color/click_color.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | 4 | from PyQt5.QtCore import QSettings 5 | from PyQt5.QtGui import QColor 6 | from PyQt5.QtWidgets import QDialog, QLabel, QPushButton, QListWidgetItem 7 | 8 | from ui.settings.default_settings import default_settings 9 | from ui.dialogs.click_color.click_colorui import Ui_Click_ColorUI 10 | from lib.rustPaletteData import rust_palette 11 | from lib.color_functions import rgb_to_hex 12 | 13 | class Click_Color(QDialog): 14 | 15 | def __init__(self, parent): 16 | """ init Colors module """ 17 | QDialog.__init__(self, parent) 18 | 19 | self.ui = Ui_Click_ColorUI() 20 | self.ui.setupUi(self) 21 | self.setWindowTitle("Click color") 22 | 23 | self.settings_window = parent 24 | self.main_window = self.settings_window.parent 25 | self.settings = QSettings() 26 | self.main_window.rustDaVinci.use_hidden_colors = bool(self.settings.value("hidden_colors", default_settings["hidden_colors"])) 27 | 28 | self.color_index = 0 29 | 30 | self.populate_list() 31 | self.connectAll() 32 | 33 | 34 | def connectAll(self): 35 | """ Connect the click button to the function """ 36 | self.ui.click_color_PushButton.clicked.connect(self.click_color_clicked) 37 | 38 | 39 | def click_color_clicked(self): 40 | """ This will click the selected color in the in-game palette """ 41 | brush_type = int(self.settings.value("brush_type", default_settings["brush_type"])) 42 | selected_color = self.ui.colors_ListWidget.currentItem().background().color() 43 | selected_color_rgb = (selected_color.red(), selected_color.green(), selected_color.blue()) 44 | color = rust_palette.index(selected_color_rgb) 45 | self.main_window.rustDaVinci.choose_painting_controls(0, brush_type, color) 46 | 47 | 48 | def populate_list(self): 49 | """ Populates the colors list """ 50 | use_hidden_colors = bool(self.settings.value("hidden_colors", default_settings["hidden_colors"])) 51 | use_brush_opacities = bool(self.settings.value("brush_opacities", default_settings["brush_opacities"])) 52 | 53 | if use_hidden_colors: 54 | if use_brush_opacities: 55 | for i, color in enumerate(rust_palette): 56 | self.append_color(color) 57 | else: 58 | for i, color in enumerate(rust_palette): 59 | if i == 64: break 60 | self.append_color(color) 61 | else: 62 | if use_brush_opacities: 63 | for i, color in enumerate(rust_palette): 64 | if (i >= 0 and i <= 19) or (i >= 64 and i <= 83) or (i >= 128 and i <= 147) or (i >= 192 and i <= 211): 65 | self.append_color(color) 66 | else: 67 | for i, color in enumerate(rust_palette): 68 | if i == 20: break 69 | self.append_color(color) 70 | 71 | 72 | def append_color(self, color): 73 | """ Appends a color to the list """ 74 | hex = rgb_to_hex(color) 75 | i = QListWidgetItem(str(self.color_index) + "\t" + str(hex)) 76 | i.setBackground(QColor(color[0], color[1], color[2])) 77 | if (color[0]*0.299 + color[1]*0.587 + color[2]*0.114) > 186: 78 | i.setForeground(QColor(0, 0, 0)) 79 | else: 80 | i.setForeground(QColor(255, 255, 255)) 81 | self.ui.colors_ListWidget.addItem(i) 82 | self.color_index += 1 83 | -------------------------------------------------------------------------------- /rustdavinci/ui/dialogs/click_color/click_colorui.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | # Form implementation generated from reading ui file 'click_colorui.ui' 4 | # 5 | # Created by: PyQt5 UI code generator 5.13.1 6 | # 7 | # WARNING! All changes made in this file will be lost! 8 | 9 | 10 | from PyQt5 import QtCore, QtGui, QtWidgets 11 | 12 | 13 | class Ui_Click_ColorUI(object): 14 | def setupUi(self, Click_ColorUI): 15 | Click_ColorUI.setObjectName("Click_ColorUI") 16 | Click_ColorUI.resize(200, 200) 17 | Click_ColorUI.setMinimumSize(QtCore.QSize(200, 200)) 18 | Click_ColorUI.setMaximumSize(QtCore.QSize(200, 200)) 19 | self.colors_ListWidget = QtWidgets.QListWidget(Click_ColorUI) 20 | self.colors_ListWidget.setGeometry(QtCore.QRect(10, 40, 181, 110)) 21 | self.colors_ListWidget.setObjectName("colors_ListWidget") 22 | self.label = QtWidgets.QLabel(Click_ColorUI) 23 | self.label.setGeometry(QtCore.QRect(16, 12, 141, 21)) 24 | self.label.setObjectName("label") 25 | self.click_color_PushButton = QtWidgets.QPushButton(Click_ColorUI) 26 | self.click_color_PushButton.setGeometry(QtCore.QRect(10, 160, 181, 31)) 27 | self.click_color_PushButton.setObjectName("click_color_PushButton") 28 | 29 | self.retranslateUi(Click_ColorUI) 30 | QtCore.QMetaObject.connectSlotsByName(Click_ColorUI) 31 | 32 | def retranslateUi(self, Click_ColorUI): 33 | _translate = QtCore.QCoreApplication.translate 34 | Click_ColorUI.setWindowTitle(_translate("Click_ColorUI", "Dialog")) 35 | self.colors_ListWidget.setToolTip(_translate("Click_ColorUI", "A list of all the available colors")) 36 | self.label.setText(_translate("Click_ColorUI", "Available colors:")) 37 | self.click_color_PushButton.setToolTip(_translate("Click_ColorUI", "This will make the application click on the selected color in the in-game palette")) 38 | self.click_color_PushButton.setText(_translate("Click_ColorUI", "Click Color")) 39 | -------------------------------------------------------------------------------- /rustdavinci/ui/dialogs/click_color/click_colorui.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | Click_ColorUI 4 | 5 | 6 | 7 | 0 8 | 0 9 | 200 10 | 200 11 | 12 | 13 | 14 | 15 | 200 16 | 200 17 | 18 | 19 | 20 | 21 | 200 22 | 200 23 | 24 | 25 | 26 | Dialog 27 | 28 | 29 | 30 | 31 | 10 32 | 40 33 | 181 34 | 110 35 | 36 | 37 | 38 | A list of all the available colors 39 | 40 | 41 | 42 | 43 | 44 | 16 45 | 12 46 | 141 47 | 21 48 | 49 | 50 | 51 | Available colors: 52 | 53 | 54 | 55 | 56 | 57 | 10 58 | 160 59 | 181 60 | 31 61 | 62 | 63 | 64 | This will make the application click on the selected color in the in-game palette 65 | 66 | 67 | Click Color 68 | 69 | 70 | 71 | 72 | 73 | 74 | -------------------------------------------------------------------------------- /rustdavinci/ui/dialogs/click_color/convert_ui.py: -------------------------------------------------------------------------------- 1 | import subprocess 2 | 3 | subprocess.run("pyuic5 click_colorui.ui -o click_colorui.py") 4 | -------------------------------------------------------------------------------- /rustdavinci/ui/dialogs/colors/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alexemanuelol/rustdavinci/89c749f78b4922383acc70b503e1e68a50c02f5f/rustdavinci/ui/dialogs/colors/__init__.py -------------------------------------------------------------------------------- /rustdavinci/ui/dialogs/colors/colors.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | 4 | from PyQt5.QtGui import QColor 5 | from PyQt5.QtWidgets import QDialog, QLabel, QPushButton, QListWidgetItem 6 | 7 | from ui.dialogs.colors.colorsui import Ui_ColorsUI 8 | from lib.rustPaletteData import rust_palette 9 | from lib.color_functions import rgb_to_hex 10 | 11 | class Colors(QDialog): 12 | 13 | def __init__(self, parent): 14 | """ init Colors module """ 15 | QDialog.__init__(self, parent) 16 | 17 | self.ui = Ui_ColorsUI() 18 | self.ui.setupUi(self) 19 | self.setWindowTitle("Colors") 20 | 21 | self.parent = parent 22 | 23 | self.populate_list() 24 | 25 | 26 | def populate_list(self): 27 | """ Populates the colors list """ 28 | for i, color in enumerate(rust_palette): 29 | hex = rgb_to_hex(color) 30 | i = QListWidgetItem(str(i) + "\t" + str(hex)) 31 | i.setBackground(QColor(color[0], color[1], color[2])) 32 | if (color[0]*0.299 + color[1]*0.587 + color[2]*0.114) > 186: 33 | i.setForeground(QColor(0, 0, 0)) 34 | else: 35 | i.setForeground(QColor(255, 255, 255)) 36 | self.ui.colors_ListWidget.addItem(i) 37 | -------------------------------------------------------------------------------- /rustdavinci/ui/dialogs/colors/colorsui.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | # Form implementation generated from reading ui file 'colorsui.ui' 4 | # 5 | # Created by: PyQt5 UI code generator 5.13.0 6 | # 7 | # WARNING! All changes made in this file will be lost! 8 | 9 | 10 | from PyQt5 import QtCore, QtGui, QtWidgets 11 | 12 | 13 | class Ui_ColorsUI(object): 14 | def setupUi(self, ColorsUI): 15 | ColorsUI.setObjectName("ColorsUI") 16 | ColorsUI.resize(200, 350) 17 | ColorsUI.setMinimumSize(QtCore.QSize(200, 350)) 18 | ColorsUI.setMaximumSize(QtCore.QSize(200, 350)) 19 | self.colors_ListWidget = QtWidgets.QListWidget(ColorsUI) 20 | self.colors_ListWidget.setGeometry(QtCore.QRect(10, 40, 181, 301)) 21 | self.colors_ListWidget.setObjectName("colors_ListWidget") 22 | self.label = QtWidgets.QLabel(ColorsUI) 23 | self.label.setGeometry(QtCore.QRect(16, 12, 141, 21)) 24 | self.label.setObjectName("label") 25 | 26 | self.retranslateUi(ColorsUI) 27 | QtCore.QMetaObject.connectSlotsByName(ColorsUI) 28 | 29 | def retranslateUi(self, ColorsUI): 30 | _translate = QtCore.QCoreApplication.translate 31 | ColorsUI.setWindowTitle(_translate("ColorsUI", "Dialog")) 32 | self.label.setText(_translate("ColorsUI", "Available colors:")) 33 | -------------------------------------------------------------------------------- /rustdavinci/ui/dialogs/colors/colorsui.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | ColorsUI 4 | 5 | 6 | 7 | 0 8 | 0 9 | 200 10 | 350 11 | 12 | 13 | 14 | 15 | 200 16 | 350 17 | 18 | 19 | 20 | 21 | 200 22 | 350 23 | 24 | 25 | 26 | Dialog 27 | 28 | 29 | 30 | 31 | 10 32 | 40 33 | 181 34 | 301 35 | 36 | 37 | 38 | 39 | 40 | 41 | 16 42 | 12 43 | 141 44 | 21 45 | 46 | 47 | 48 | Available colors: 49 | 50 | 51 | 52 | 53 | 54 | 55 | -------------------------------------------------------------------------------- /rustdavinci/ui/dialogs/colors/convert_ui.py: -------------------------------------------------------------------------------- 1 | import subprocess 2 | 3 | subprocess.run("pyuic5 colorsui.ui -o colorsui.py") 4 | -------------------------------------------------------------------------------- /rustdavinci/ui/resources/brushes/heavy_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alexemanuelol/rustdavinci/89c749f78b4922383acc70b503e1e68a50c02f5f/rustdavinci/ui/resources/brushes/heavy_round.png -------------------------------------------------------------------------------- /rustdavinci/ui/resources/brushes/heavy_square.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alexemanuelol/rustdavinci/89c749f78b4922383acc70b503e1e68a50c02f5f/rustdavinci/ui/resources/brushes/heavy_square.png -------------------------------------------------------------------------------- /rustdavinci/ui/resources/brushes/light_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alexemanuelol/rustdavinci/89c749f78b4922383acc70b503e1e68a50c02f5f/rustdavinci/ui/resources/brushes/light_round.png -------------------------------------------------------------------------------- /rustdavinci/ui/resources/brushes/medium_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alexemanuelol/rustdavinci/89c749f78b4922383acc70b503e1e68a50c02f5f/rustdavinci/ui/resources/brushes/medium_round.png -------------------------------------------------------------------------------- /rustdavinci/ui/resources/convert_qrc.py: -------------------------------------------------------------------------------- 1 | import subprocess 2 | 3 | subprocess.run("pyrcc5 icons.qrc -o icons_rc.py") 4 | -------------------------------------------------------------------------------- /rustdavinci/ui/resources/gifs/capture_canvas.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alexemanuelol/rustdavinci/89c749f78b4922383acc70b503e1e68a50c02f5f/rustdavinci/ui/resources/gifs/capture_canvas.gif -------------------------------------------------------------------------------- /rustdavinci/ui/resources/gifs/capture_ctrl_area.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alexemanuelol/rustdavinci/89c749f78b4922383acc70b503e1e68a50c02f5f/rustdavinci/ui/resources/gifs/capture_ctrl_area.gif -------------------------------------------------------------------------------- /rustdavinci/ui/resources/icons.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | icons/load_image_icon.png 4 | icons/select_area_icon.png 5 | icons/paint_image_icon.png 6 | icons/settings_icon.png 7 | icons/RustDaVinci-icon.ico 8 | icons/RustDaVinci-logo-1.png 9 | icons/RustDaVinci-logo-2.png 10 | 11 | brushes/light_round.png 12 | brushes/heavy_round.png 13 | brushes/medium_round.png 14 | brushes/heavy_square.png 15 | 16 | gifs/capture_canvas.gif 17 | gifs/capture_ctrl_area.gif 18 | 19 | 20 | -------------------------------------------------------------------------------- /rustdavinci/ui/resources/icons/RustDaVinci-icon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alexemanuelol/rustdavinci/89c749f78b4922383acc70b503e1e68a50c02f5f/rustdavinci/ui/resources/icons/RustDaVinci-icon.ico -------------------------------------------------------------------------------- /rustdavinci/ui/resources/icons/RustDaVinci-logo-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alexemanuelol/rustdavinci/89c749f78b4922383acc70b503e1e68a50c02f5f/rustdavinci/ui/resources/icons/RustDaVinci-logo-1.png -------------------------------------------------------------------------------- /rustdavinci/ui/resources/icons/RustDaVinci-logo-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alexemanuelol/rustdavinci/89c749f78b4922383acc70b503e1e68a50c02f5f/rustdavinci/ui/resources/icons/RustDaVinci-logo-2.png -------------------------------------------------------------------------------- /rustdavinci/ui/resources/icons/load_image_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alexemanuelol/rustdavinci/89c749f78b4922383acc70b503e1e68a50c02f5f/rustdavinci/ui/resources/icons/load_image_icon.png -------------------------------------------------------------------------------- /rustdavinci/ui/resources/icons/paint_image_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alexemanuelol/rustdavinci/89c749f78b4922383acc70b503e1e68a50c02f5f/rustdavinci/ui/resources/icons/paint_image_icon.png -------------------------------------------------------------------------------- /rustdavinci/ui/resources/icons/select_area_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alexemanuelol/rustdavinci/89c749f78b4922383acc70b503e1e68a50c02f5f/rustdavinci/ui/resources/icons/select_area_icon.png -------------------------------------------------------------------------------- /rustdavinci/ui/resources/icons/settings_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alexemanuelol/rustdavinci/89c749f78b4922383acc70b503e1e68a50c02f5f/rustdavinci/ui/resources/icons/settings_icon.png -------------------------------------------------------------------------------- /rustdavinci/ui/settings/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alexemanuelol/rustdavinci/89c749f78b4922383acc70b503e1e68a50c02f5f/rustdavinci/ui/settings/__init__.py -------------------------------------------------------------------------------- /rustdavinci/ui/settings/convert_ui.py: -------------------------------------------------------------------------------- 1 | import subprocess 2 | 3 | subprocess.run("pyuic5 settingsui.ui -o settingsui.py") 4 | 5 | s = open("settingsui.py").read() 6 | s = s.replace("import icons_rc", "import ui.resources.icons_rc") 7 | f = open("settingsui.py", "w") 8 | f.write(s) 9 | f.close() 10 | -------------------------------------------------------------------------------- /rustdavinci/ui/settings/default_settings.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | 4 | 5 | default_settings = { 6 | "window_topmost": 1, 7 | "quality": 0, 8 | "ctrl_x": 0, 9 | "ctrl_y": 0, 10 | "ctrl_w": 0, 11 | "ctrl_h": 0, 12 | "skip_background_color": 1, 13 | "background_color": "#ECF0F1", 14 | "skip_colors": [], 15 | "pause_key": "f10", 16 | "skip_key": "f11", 17 | "abort_key": "esc", 18 | "update_canvas": 1, 19 | "update_canvas_end": 1, 20 | "draw_lines": 1, 21 | "double_click": 0, 22 | "show_information": 1, 23 | "show_preview_load": 1, 24 | "hide_preview_paint": 1, 25 | "paint_background": 0, 26 | "brush_opacities": 1, 27 | "hidden_colors": 0, 28 | "click_delay": 20, 29 | "ctrl_area_delay": 180, 30 | "line_delay": 30, 31 | "minimum_line_width": 10, 32 | "brush_type": 1 33 | } 34 | -------------------------------------------------------------------------------- /rustdavinci/ui/settings/settings.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | 4 | from PyQt5.QtCore import QSettings, Qt 5 | from PyQt5.QtGui import QPalette, QColor 6 | from PyQt5.QtWidgets import QDialog, QColorDialog, QListWidgetItem 7 | 8 | import sys 9 | 10 | from ui.settings.default_settings import default_settings 11 | from ui.settings.settingsui import Ui_SettingsUI 12 | from lib.color_functions import hex_to_rgb, rgb_to_hex, closest_color 13 | from lib.captureArea import show_area 14 | from ui.dialogs.colors.colors import Colors 15 | from ui.dialogs.click_color.click_color import Click_Color 16 | 17 | 18 | class Settings(QDialog): 19 | def __init__(self, parent): 20 | """ Settings init module """ 21 | QDialog.__init__(self, parent) 22 | 23 | # Setup UI 24 | self.ui = Ui_SettingsUI() 25 | self.ui.setupUi(self) 26 | 27 | # Setup parent object 28 | self.parent = parent 29 | 30 | # Setup Settings 31 | self.settings = QSettings() 32 | self.isSettingsChanged = False 33 | self.isColorsOpened = False 34 | 35 | if not (int(self.settings.value("ctrl_w", default_settings["ctrl_w"])) == 0 or int(self.settings.value("ctrl_h", default_settings["ctrl_h"])) == 0): 36 | self.parent.rustDaVinci.calculate_ctrl_tools_positioning() 37 | self.ui.show_ctrl_PushButton.setEnabled(True) 38 | self.ui.click_color_PushButton.setEnabled(True) 39 | else: 40 | self.ui.show_ctrl_PushButton.setEnabled(False) 41 | self.ui.click_color_PushButton.setEnabled(False) 42 | 43 | self.qpalette = QPalette() 44 | 45 | self.availableColors = Colors(self) 46 | 47 | # Uncomment line below if you want to clear the settings everytime you start an instance 48 | #self.settings.clear() 49 | 50 | # Load settings and connect UI modules 51 | self.loadSettings() 52 | self.connectAll() 53 | 54 | 55 | def connectAll(self): 56 | """ Connect all buttons/checkboxes/comboboxes/lineedits. """ 57 | # Buttons 58 | self.ui.default_PushButton.clicked.connect(self.default_clicked) 59 | self.ui.ok_PushButton.clicked.connect(self.ok_clicked) 60 | self.ui.cancel_PushButton.clicked.connect(self.close) 61 | self.ui.apply_PushButton.clicked.connect(self.apply_clicked) 62 | self.ui.clear_coords_PushButton.clicked.connect(self.clear_coords_clicked) 63 | self.ui.show_ctrl_PushButton.clicked.connect(self.show_ctrl_clicked) 64 | self.ui.color_picker_PushButton.clicked.connect(self.color_picker_clicked) 65 | self.ui.add_skip_color_PushButton.clicked.connect(self.add_skip_color_clicked) 66 | self.ui.remove_skip_color_PushButton.clicked.connect(self.remove_skip_color_clicked) 67 | self.ui.available_colors_PushButton.clicked.connect(self.available_colors_clicked) 68 | self.ui.click_color_PushButton.clicked.connect(self.click_color_clicked) 69 | 70 | # Checkboxes 71 | self.ui.topmost_CheckBox.stateChanged.connect(self.enableApply) 72 | self.ui.skip_background_CheckBox.stateChanged.connect(self.enableApply) 73 | self.ui.update_canvas_CheckBox.stateChanged.connect(self.enableApply) 74 | self.ui.update_canvas_end_CheckBox.stateChanged.connect(self.enableApply) 75 | self.ui.draw_lines_CheckBox.stateChanged.connect(self.enableApply) 76 | self.ui.double_click_CheckBox.stateChanged.connect(self.enableApply) 77 | self.ui.show_info_CheckBox.stateChanged.connect(self.enableApply) 78 | self.ui.show_preview_CheckBox.stateChanged.connect(self.enableApply) 79 | self.ui.hide_preview_CheckBox.stateChanged.connect(self.enableApply) 80 | self.ui.paint_background_CheckBox.stateChanged.connect(self.enableApply) 81 | self.ui.opacities_CheckBox.stateChanged.connect(self.enableApply) 82 | self.ui.hidden_colors_CheckBox.stateChanged.connect(self.enableApply) 83 | 84 | # Comboboxes 85 | self.ui.quality_ComboBox.currentIndexChanged.connect(self.enableApply) 86 | self.ui.brush_type_ComboBox.currentIndexChanged.connect(self.enableApply) 87 | 88 | # Lineedits 89 | self.ui.ctrl_x_LineEdit.textChanged.connect(self.enableApply) 90 | self.ui.ctrl_y_LineEdit.textChanged.connect(self.enableApply) 91 | self.ui.ctrl_w_LineEdit.textChanged.connect(self.enableApply) 92 | self.ui.ctrl_h_LineEdit.textChanged.connect(self.enableApply) 93 | self.ui.pause_key_LineEdit.textChanged.connect(self.enableApply) 94 | self.ui.skip_key_LineEdit.textChanged.connect(self.enableApply) 95 | self.ui.abort_key_LineEdit.textChanged.connect(self.enableApply) 96 | self.ui.background_LineEdit.textChanged.connect(self.enableApply) 97 | self.ui.click_delay_LineEdit.textChanged.connect(self.enableApply) 98 | self.ui.ctrl_delay_LineEdit.textChanged.connect(self.enableApply) 99 | self.ui.line_delay_LineEdit.textChanged.connect(self.enableApply) 100 | self.ui.min_line_width_LineEdit.textChanged.connect(self.enableApply) 101 | 102 | 103 | def enableApply(self): 104 | """ When a settings is changed, enable the apply button. """ 105 | self.isSettingsChanged = True 106 | self.ui.apply_PushButton.setEnabled(True) 107 | 108 | 109 | def loadSettings(self): 110 | """ Load the saved settings or the default settings. """ 111 | # Checkboxes 112 | self.setting_to_checkbox("window_topmost", self.ui.topmost_CheckBox, default_settings["window_topmost"]) 113 | self.setting_to_checkbox("skip_background_color", self.ui.skip_background_CheckBox, default_settings["skip_background_color"]) 114 | self.setting_to_checkbox("update_canvas", self.ui.update_canvas_CheckBox, default_settings["update_canvas"]) 115 | self.setting_to_checkbox("update_canvas_end", self.ui.update_canvas_end_CheckBox, default_settings["update_canvas_end"]) 116 | self.setting_to_checkbox("draw_lines", self.ui.draw_lines_CheckBox, default_settings["draw_lines"]) 117 | self.setting_to_checkbox("double_click", self.ui.double_click_CheckBox, default_settings["double_click"]) 118 | self.setting_to_checkbox("show_information", self.ui.show_info_CheckBox, default_settings["show_information"]) 119 | self.setting_to_checkbox("show_preview_load", self.ui.show_preview_CheckBox, default_settings["show_preview_load"]) 120 | self.setting_to_checkbox("hide_preview_paint", self.ui.hide_preview_CheckBox, default_settings["hide_preview_paint"]) 121 | self.setting_to_checkbox("paint_background", self.ui.paint_background_CheckBox, default_settings["paint_background"]) 122 | self.setting_to_checkbox("brush_opacities", self.ui.opacities_CheckBox, default_settings["brush_opacities"]) 123 | self.setting_to_checkbox("hidden_colors", self.ui.hidden_colors_CheckBox, default_settings["hidden_colors"]) 124 | 125 | # Comboboxes 126 | index = self.settings.value("quality", default_settings["quality"]) 127 | self.ui.quality_ComboBox.setCurrentIndex(index) 128 | index = self.settings.value("brush_type", default_settings["brush_type"]) 129 | self.ui.brush_type_ComboBox.setCurrentIndex(index) 130 | 131 | # Lineedits 132 | ctrl_x = str(self.settings.value("ctrl_x", default_settings["ctrl_x"])) 133 | self.ui.ctrl_x_LineEdit.setText(ctrl_x) 134 | ctrl_y = str(self.settings.value("ctrl_y", default_settings["ctrl_y"])) 135 | self.ui.ctrl_y_LineEdit.setText(ctrl_y) 136 | ctrl_w = str(self.settings.value("ctrl_w", default_settings["ctrl_w"])) 137 | self.ui.ctrl_w_LineEdit.setText(ctrl_w) 138 | ctrl_h = str(self.settings.value("ctrl_h", default_settings["ctrl_h"])) 139 | self.ui.ctrl_h_LineEdit.setText(ctrl_h) 140 | pause_key = self.settings.value("pause_key", default_settings["pause_key"]) 141 | self.ui.pause_key_LineEdit.setText(pause_key) 142 | skip_key = self.settings.value("skip_key", default_settings["skip_key"]) 143 | self.ui.skip_key_LineEdit.setText(skip_key) 144 | abort_key = self.settings.value("abort_key", default_settings["abort_key"]) 145 | self.ui.abort_key_LineEdit.setText(abort_key) 146 | 147 | background_color = self.settings.value("background_color", default_settings["background_color"]) 148 | rgb = hex_to_rgb(background_color) 149 | if (rgb[0]*0.299 + rgb[1]*0.587 + rgb[2]*0.114) > 186: 150 | self.qpalette.setColor(QPalette.Text, QColor(0, 0, 0)) 151 | else: 152 | self.qpalette.setColor(QPalette.Text, QColor(255, 255, 255)) 153 | self.qpalette.setColor(QPalette.Base, QColor(rgb[0], rgb[1], rgb[2])) 154 | self.ui.background_LineEdit.setPalette(self.qpalette) 155 | self.ui.background_LineEdit.setText(background_color) 156 | 157 | click_delay = str(self.settings.value("click_delay", default_settings["click_delay"])) 158 | self.ui.click_delay_LineEdit.setText(click_delay) 159 | ctrl_area_delay = str(self.settings.value("ctrl_area_delay", default_settings["ctrl_area_delay"])) 160 | self.ui.ctrl_delay_LineEdit.setText(ctrl_area_delay) 161 | line_delay = str(self.settings.value("line_delay", default_settings["line_delay"])) 162 | self.ui.line_delay_LineEdit.setText(line_delay) 163 | minimum_line_width = str(self.settings.value("minimum_line_width", default_settings["minimum_line_width"])) 164 | self.ui.min_line_width_LineEdit.setText(minimum_line_width) 165 | 166 | # Listwidgets 167 | skip_colors = self.settings.value("skip_colors", default_settings["skip_colors"], "QStringList") 168 | if len(skip_colors) != 0: 169 | for color in skip_colors: 170 | rgb = hex_to_rgb(color) 171 | i = QListWidgetItem(color) 172 | i.setBackground(QColor(rgb[0], rgb[1], rgb[2])) 173 | if (rgb[0]*0.299 + rgb[1]*0.587 + rgb[2]*0.114) > 186: 174 | i.setForeground(QColor(0, 0, 0)) 175 | else: 176 | i.setForeground(QColor(255, 255, 255)) 177 | self.ui.skip_colors_ListWidget.addItem(i) 178 | 179 | 180 | def setting_to_checkbox(self, name, checkBox, default): 181 | """ Settings integer values converted to checkbox """ 182 | val = int(self.settings.value(name, default)) 183 | if val: checkBox.setCheckState(Qt.Checked) 184 | else: checkBox.setCheckState(Qt.Unchecked) 185 | 186 | 187 | def saveSettings(self): 188 | """ Save settings. """ 189 | # Checkboxes 190 | self.checkbox_to_setting("window_topmost", self.ui.topmost_CheckBox.isChecked()) 191 | self.checkbox_to_setting("skip_background_color", self.ui.skip_background_CheckBox.isChecked()) 192 | self.checkbox_to_setting("update_canvas", self.ui.update_canvas_CheckBox.isChecked()) 193 | self.checkbox_to_setting("update_canvas_end", self.ui.update_canvas_end_CheckBox.isChecked()) 194 | self.checkbox_to_setting("draw_lines", self.ui.draw_lines_CheckBox.isChecked()) 195 | self.checkbox_to_setting("double_click", self.ui.double_click_CheckBox.isChecked()) 196 | self.checkbox_to_setting("show_information", self.ui.show_info_CheckBox.isChecked()) 197 | self.checkbox_to_setting("show_preview_load", self.ui.show_preview_CheckBox.isChecked()) 198 | self.checkbox_to_setting("hide_preview_paint", self.ui.hide_preview_CheckBox.isChecked()) 199 | self.checkbox_to_setting("paint_background", self.ui.paint_background_CheckBox.isChecked()) 200 | self.checkbox_to_setting("brush_opacities", self.ui.opacities_CheckBox.isChecked()) 201 | self.checkbox_to_setting("hidden_colors", self.ui.hidden_colors_CheckBox.isChecked()) 202 | 203 | # Comboboxes 204 | self.settings.setValue("quality", self.ui.quality_ComboBox.currentIndex()) 205 | self.settings.setValue("brush_type", self.ui.brush_type_ComboBox.currentIndex()) 206 | 207 | # Lineedits 208 | self.settings.setValue("ctrl_x", self.ui.ctrl_x_LineEdit.text()) 209 | self.settings.setValue("ctrl_y", self.ui.ctrl_y_LineEdit.text()) 210 | self.settings.setValue("ctrl_w", self.ui.ctrl_w_LineEdit.text()) 211 | self.settings.setValue("ctrl_h", self.ui.ctrl_h_LineEdit.text()) 212 | self.settings.setValue("pause_key", self.ui.pause_key_LineEdit.text()) 213 | self.settings.setValue("skip_key", self.ui.skip_key_LineEdit.text()) 214 | self.settings.setValue("abort_key", self.ui.abort_key_LineEdit.text()) 215 | self.settings.setValue("background_color", self.ui.background_LineEdit.text()) 216 | self.settings.setValue("click_delay", self.ui.click_delay_LineEdit.text()) 217 | self.settings.setValue("ctrl_area_delay", self.ui.ctrl_delay_LineEdit.text()) 218 | self.settings.setValue("line_delay", self.ui.line_delay_LineEdit.text()) 219 | self.settings.setValue("minimum_line_width", self.ui.min_line_width_LineEdit.text()) 220 | 221 | # Skip color list 222 | if self.ui.skip_colors_ListWidget.count() != 0: 223 | temp_list = [] 224 | for i in range(self.ui.skip_colors_ListWidget.count()): 225 | temp_list.append(self.ui.skip_colors_ListWidget.item(i).text()) 226 | self.settings.setValue("skip_colors", temp_list) 227 | else: 228 | self.settings.setValue("skip_colors", []) 229 | 230 | 231 | self.parent.rustDaVinci.update() 232 | 233 | if self.parent.rustDaVinci.org_img != None: 234 | self.parent.rustDaVinci.convert_transparency() 235 | self.parent.rustDaVinci.create_pixmaps() 236 | if self.parent.is_expanded: 237 | self.parent.label.hide() 238 | self.parent.expand_window() 239 | 240 | if not (int(self.settings.value("ctrl_w", default_settings["ctrl_w"])) == 0 or int(self.settings.value("ctrl_h", default_settings["ctrl_h"])) == 0): 241 | self.parent.rustDaVinci.calculate_ctrl_tools_positioning() 242 | self.ui.show_ctrl_PushButton.setEnabled(True) 243 | self.ui.click_color_PushButton.setEnabled(True) 244 | else: 245 | self.ui.show_ctrl_PushButton.setEnabled(False) 246 | self.ui.click_color_PushButton.setEnabled(False) 247 | 248 | 249 | def checkbox_to_setting(self, name, val): 250 | """ Settings save checkbox to integer """ 251 | if val: self.settings.setValue(name, 1) 252 | else: self.settings.setValue(name, 0) 253 | 254 | 255 | def default_clicked(self): 256 | """ Set everything to the default values. """ 257 | # Checkboxes 258 | self.ui.topmost_CheckBox.setCheckState(Qt.Checked) 259 | self.ui.skip_background_CheckBox.setCheckState(Qt.Checked) 260 | self.ui.update_canvas_CheckBox.setCheckState(Qt.Checked) 261 | self.ui.update_canvas_end_CheckBox.setCheckState(Qt.Checked) 262 | self.ui.draw_lines_CheckBox.setCheckState(Qt.Checked) 263 | self.ui.double_click_CheckBox.setCheckState(Qt.Unchecked) 264 | self.ui.show_info_CheckBox.setCheckState(Qt.Checked) 265 | self.ui.show_preview_CheckBox.setCheckState(Qt.Unchecked) 266 | self.ui.hide_preview_CheckBox.setCheckState(Qt.Unchecked) 267 | self.ui.paint_background_CheckBox.setCheckState(Qt.Unchecked) 268 | self.ui.opacities_CheckBox.setCheckState(Qt.Checked) 269 | self.ui.hidden_colors_CheckBox.setCheckState(Qt.Unchecked) 270 | 271 | # Comboboxes 272 | self.ui.quality_ComboBox.setCurrentIndex(default_settings["quality"]) 273 | self.ui.brush_type_ComboBox.setCurrentIndex(default_settings["brush_type"]) 274 | 275 | # Lineedits 276 | self.ui.ctrl_x_LineEdit.setText(str(default_settings["ctrl_x"])) 277 | self.ui.ctrl_y_LineEdit.setText(str(default_settings["ctrl_y"])) 278 | self.ui.ctrl_w_LineEdit.setText(str(default_settings["ctrl_w"])) 279 | self.ui.ctrl_h_LineEdit.setText(str(default_settings["ctrl_h"])) 280 | self.ui.pause_key_LineEdit.setText(default_settings["pause_key"]) 281 | self.ui.skip_key_LineEdit.setText(default_settings["skip_key"]) 282 | self.ui.abort_key_LineEdit.setText(default_settings["abort_key"]) 283 | 284 | rgb = hex_to_rgb(default_settings["background_color"]) 285 | if (rgb[0]*0.299 + rgb[1]*0.587 + rgb[2]*0.114) > 186: 286 | self.qpalette.setColor(QPalette.Text, QColor(0, 0, 0)) 287 | else: 288 | self.qpalette.setColor(QPalette.Text, QColor(255, 255, 255)) 289 | self.qpalette.setColor(QPalette.Base, QColor(rgb[0], rgb[1], rgb[2])) 290 | self.ui.background_LineEdit.setPalette(self.qpalette) 291 | self.ui.background_LineEdit.setText(default_settings["background_color"]) 292 | 293 | self.ui.click_delay_LineEdit.setText(str(default_settings["click_delay"])) 294 | self.ui.ctrl_delay_LineEdit.setText(str(default_settings["ctrl_area_delay"])) 295 | self.ui.line_delay_LineEdit.setText(str(default_settings["line_delay"])) 296 | self.ui.min_line_width_LineEdit.setText(str(default_settings["minimum_line_width"])) 297 | 298 | # Set skip color list to default 299 | self.ui.skip_colors_ListWidget.clear() 300 | if default_settings["skip_colors"] != []: 301 | for hex in default_settings["skip_colors"]: 302 | rgb = hex_to_rgb(hex) 303 | i = QListWidgetItem(hex) 304 | i.setBackground(QColor(rgb[0], rgb[1], rgb[2])) 305 | if (rgb[0]*0.299 + rgb[1]*0.587 + rgb[2]*0.114) > 186: 306 | i.setForeground(QColor(0, 0, 0)) 307 | else: 308 | i.setForeground(QColor(255, 255, 255)) 309 | self.ui.skip_colors_ListWidget.addItem(i) 310 | 311 | 312 | def ok_clicked(self): 313 | """ Save and quit settings. """ 314 | if self.isSettingsChanged: self.saveSettings() 315 | self.close() 316 | 317 | 318 | def cancel_clicked(self): 319 | """ quit settings. """ 320 | self.close() 321 | 322 | 323 | def apply_clicked(self): 324 | """ Apply the settings. """ 325 | self.saveSettings() 326 | self.isSettingsChanged = False 327 | self.ui.apply_PushButton.setEnabled(False) 328 | 329 | 330 | def clear_coords_clicked(self): 331 | """ Clear the control area coordinates. """ 332 | self.ui.ctrl_x_LineEdit.setText(str(default_settings["ctrl_x"])) 333 | self.ui.ctrl_y_LineEdit.setText(str(default_settings["ctrl_y"])) 334 | self.ui.ctrl_w_LineEdit.setText(str(default_settings["ctrl_w"])) 335 | self.ui.ctrl_h_LineEdit.setText(str(default_settings["ctrl_h"])) 336 | 337 | 338 | def show_ctrl_clicked(self): 339 | """ Show where control area is located """ 340 | x = int(self.settings.value("ctrl_x", default_settings["ctrl_x"])) 341 | y = int(self.settings.value("ctrl_y", default_settings["ctrl_y"])) 342 | w = int(self.settings.value("ctrl_w", default_settings["ctrl_w"])) 343 | h = int(self.settings.value("ctrl_h", default_settings["ctrl_h"])) 344 | show_area(x, y, w, h) 345 | 346 | 347 | def color_picker_clicked(self): 348 | """ Open a QColorDialog window """ 349 | rgb = hex_to_rgb(self.ui.background_LineEdit.text()) 350 | colorDialog = QColorDialog() 351 | selected_color = colorDialog.getColor(QColor(rgb[0], rgb[1], rgb[2]), self, "Select the default background color") 352 | if selected_color.isValid(): 353 | color = closest_color(hex_to_rgb(selected_color.name())) 354 | if (color[0]*0.299 + color[1]*0.587 + color[2]*0.114) > 186: 355 | self.qpalette.setColor(QPalette.Text, QColor(0, 0, 0)) 356 | else: 357 | self.qpalette.setColor(QPalette.Text, QColor(255, 255, 255)) 358 | self.qpalette.setColor(QPalette.Base, QColor(color[0], color[1], color[2])) 359 | self.ui.background_LineEdit.setPalette(self.qpalette) 360 | hex = rgb_to_hex(color) 361 | self.ui.background_LineEdit.setText(hex) 362 | 363 | 364 | def add_skip_color_clicked(self): 365 | """ Add a color to skip_colors """ 366 | colorDialog = QColorDialog() 367 | selected_color = colorDialog.getColor(QColor(255, 255, 255), self, "Select a color that should be skipped in the painting process") 368 | if selected_color.isValid(): 369 | color = closest_color(hex_to_rgb(selected_color.name())) 370 | hex = rgb_to_hex(color) 371 | 372 | # Verify that the color does not already exist in the list 373 | for i in range(self.ui.skip_colors_ListWidget.count()): 374 | if self.ui.skip_colors_ListWidget.item(i).text() == hex: 375 | return 376 | 377 | i = QListWidgetItem(hex) 378 | i.setBackground(QColor(color[0], color[1], color[2])) 379 | if (color[0]*0.299 + color[1]*0.587 + color[2]*0.114) > 186: 380 | i.setForeground(QColor(0, 0, 0)) 381 | else: 382 | i.setForeground(QColor(255, 255, 255)) 383 | self.ui.skip_colors_ListWidget.addItem(i) 384 | self.enableApply() 385 | 386 | 387 | def remove_skip_color_clicked(self): 388 | """ Remove a color from skip_colors """ 389 | listItems = self.ui.skip_colors_ListWidget.selectedItems() 390 | if not listItems: return 391 | for item in listItems: 392 | self.ui.skip_colors_ListWidget.takeItem(self.ui.skip_colors_ListWidget.row(item)) 393 | self.enableApply() 394 | 395 | 396 | def available_colors_clicked(self): 397 | """ Opens a dialog with all available colors """ 398 | if not self.availableColors.isVisible(): 399 | self.availableColors.show() 400 | 401 | 402 | def click_color_clicked(self): 403 | """ Opens a dialog in which you can select a color to be clicked in-game """ 404 | clickColor = Click_Color(self) 405 | clickColor.exec_() 406 | 407 | 408 | def closeEvent(self, event): 409 | """ CloseEvent """ 410 | self.availableColors.hide() 411 | -------------------------------------------------------------------------------- /rustdavinci/ui/settings/settingsui.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | # Form implementation generated from reading ui file 'settingsui.ui' 4 | # 5 | # Created by: PyQt5 UI code generator 5.13.1 6 | # 7 | # WARNING! All changes made in this file will be lost! 8 | 9 | 10 | from PyQt5 import QtCore, QtGui, QtWidgets 11 | 12 | 13 | class Ui_SettingsUI(object): 14 | def setupUi(self, SettingsUI): 15 | SettingsUI.setObjectName("SettingsUI") 16 | SettingsUI.resize(391, 510) 17 | sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Preferred) 18 | sizePolicy.setHorizontalStretch(0) 19 | sizePolicy.setVerticalStretch(0) 20 | sizePolicy.setHeightForWidth(SettingsUI.sizePolicy().hasHeightForWidth()) 21 | SettingsUI.setSizePolicy(sizePolicy) 22 | SettingsUI.setMinimumSize(QtCore.QSize(391, 510)) 23 | SettingsUI.setMaximumSize(QtCore.QSize(391, 510)) 24 | self.tabWidget = QtWidgets.QTabWidget(SettingsUI) 25 | self.tabWidget.setGeometry(QtCore.QRect(6, 9, 381, 461)) 26 | self.tabWidget.setTabShape(QtWidgets.QTabWidget.Rounded) 27 | self.tabWidget.setObjectName("tabWidget") 28 | self.generalTab = QtWidgets.QWidget() 29 | self.generalTab.setObjectName("generalTab") 30 | self.line_1 = QtWidgets.QFrame(self.generalTab) 31 | self.line_1.setGeometry(QtCore.QRect(10, 70, 351, 20)) 32 | self.line_1.setFrameShape(QtWidgets.QFrame.HLine) 33 | self.line_1.setFrameShadow(QtWidgets.QFrame.Sunken) 34 | self.line_1.setObjectName("line_1") 35 | self.quality_ComboBox = QtWidgets.QComboBox(self.generalTab) 36 | self.quality_ComboBox.setGeometry(QtCore.QRect(180, 40, 171, 22)) 37 | self.quality_ComboBox.setObjectName("quality_ComboBox") 38 | self.quality_ComboBox.addItem("") 39 | self.quality_ComboBox.addItem("") 40 | self.label_1 = QtWidgets.QLabel(self.generalTab) 41 | self.label_1.setGeometry(QtCore.QRect(20, 40, 161, 21)) 42 | self.label_1.setObjectName("label_1") 43 | self.label_4 = QtWidgets.QLabel(self.generalTab) 44 | self.label_4.setGeometry(QtCore.QRect(20, 130, 161, 20)) 45 | self.label_4.setObjectName("label_4") 46 | self.label_7 = QtWidgets.QLabel(self.generalTab) 47 | self.label_7.setGeometry(QtCore.QRect(300, 110, 51, 20)) 48 | self.label_7.setObjectName("label_7") 49 | self.label_9 = QtWidgets.QLabel(self.generalTab) 50 | self.label_9.setGeometry(QtCore.QRect(300, 150, 51, 20)) 51 | self.label_9.setObjectName("label_9") 52 | self.ctrl_y_LineEdit = QtWidgets.QLineEdit(self.generalTab) 53 | self.ctrl_y_LineEdit.setGeometry(QtCore.QRect(180, 110, 101, 20)) 54 | self.ctrl_y_LineEdit.setObjectName("ctrl_y_LineEdit") 55 | self.clear_coords_PushButton = QtWidgets.QPushButton(self.generalTab) 56 | self.clear_coords_PushButton.setGeometry(QtCore.QRect(130, 180, 101, 23)) 57 | self.clear_coords_PushButton.setFocusPolicy(QtCore.Qt.StrongFocus) 58 | self.clear_coords_PushButton.setDefault(False) 59 | self.clear_coords_PushButton.setObjectName("clear_coords_PushButton") 60 | self.ctrl_h_LineEdit = QtWidgets.QLineEdit(self.generalTab) 61 | self.ctrl_h_LineEdit.setGeometry(QtCore.QRect(180, 150, 101, 20)) 62 | self.ctrl_h_LineEdit.setObjectName("ctrl_h_LineEdit") 63 | self.ctrl_w_LineEdit = QtWidgets.QLineEdit(self.generalTab) 64 | self.ctrl_w_LineEdit.setGeometry(QtCore.QRect(180, 130, 101, 20)) 65 | self.ctrl_w_LineEdit.setObjectName("ctrl_w_LineEdit") 66 | self.label_2 = QtWidgets.QLabel(self.generalTab) 67 | self.label_2.setGeometry(QtCore.QRect(20, 90, 161, 20)) 68 | self.label_2.setObjectName("label_2") 69 | self.label_8 = QtWidgets.QLabel(self.generalTab) 70 | self.label_8.setGeometry(QtCore.QRect(300, 130, 51, 20)) 71 | self.label_8.setObjectName("label_8") 72 | self.label_6 = QtWidgets.QLabel(self.generalTab) 73 | self.label_6.setGeometry(QtCore.QRect(300, 90, 51, 20)) 74 | self.label_6.setObjectName("label_6") 75 | self.ctrl_x_LineEdit = QtWidgets.QLineEdit(self.generalTab) 76 | self.ctrl_x_LineEdit.setGeometry(QtCore.QRect(180, 90, 101, 20)) 77 | self.ctrl_x_LineEdit.setObjectName("ctrl_x_LineEdit") 78 | self.label_5 = QtWidgets.QLabel(self.generalTab) 79 | self.label_5.setGeometry(QtCore.QRect(20, 150, 161, 20)) 80 | self.label_5.setObjectName("label_5") 81 | self.label_3 = QtWidgets.QLabel(self.generalTab) 82 | self.label_3.setGeometry(QtCore.QRect(20, 110, 161, 20)) 83 | self.label_3.setObjectName("label_3") 84 | self.topmost_CheckBox = QtWidgets.QCheckBox(self.generalTab) 85 | self.topmost_CheckBox.setGeometry(QtCore.QRect(20, 20, 341, 17)) 86 | self.topmost_CheckBox.setChecked(True) 87 | self.topmost_CheckBox.setObjectName("topmost_CheckBox") 88 | self.line_7 = QtWidgets.QFrame(self.generalTab) 89 | self.line_7.setGeometry(QtCore.QRect(10, 200, 351, 20)) 90 | self.line_7.setFrameShape(QtWidgets.QFrame.HLine) 91 | self.line_7.setFrameShadow(QtWidgets.QFrame.Sunken) 92 | self.line_7.setObjectName("line_7") 93 | self.skip_background_CheckBox = QtWidgets.QCheckBox(self.generalTab) 94 | self.skip_background_CheckBox.setGeometry(QtCore.QRect(20, 230, 341, 17)) 95 | self.skip_background_CheckBox.setChecked(True) 96 | self.skip_background_CheckBox.setObjectName("skip_background_CheckBox") 97 | self.label_13 = QtWidgets.QLabel(self.generalTab) 98 | self.label_13.setGeometry(QtCore.QRect(20, 250, 161, 21)) 99 | self.label_13.setObjectName("label_13") 100 | self.color_picker_PushButton = QtWidgets.QPushButton(self.generalTab) 101 | self.color_picker_PushButton.setGeometry(QtCore.QRect(320, 250, 31, 20)) 102 | self.color_picker_PushButton.setObjectName("color_picker_PushButton") 103 | self.background_LineEdit = QtWidgets.QLineEdit(self.generalTab) 104 | self.background_LineEdit.setGeometry(QtCore.QRect(180, 250, 131, 20)) 105 | self.background_LineEdit.setAlignment(QtCore.Qt.AlignCenter) 106 | self.background_LineEdit.setReadOnly(True) 107 | self.background_LineEdit.setObjectName("background_LineEdit") 108 | self.skip_colors_ListWidget = QtWidgets.QListWidget(self.generalTab) 109 | self.skip_colors_ListWidget.setGeometry(QtCore.QRect(20, 310, 241, 111)) 110 | self.skip_colors_ListWidget.setObjectName("skip_colors_ListWidget") 111 | self.add_skip_color_PushButton = QtWidgets.QPushButton(self.generalTab) 112 | self.add_skip_color_PushButton.setGeometry(QtCore.QRect(270, 310, 81, 23)) 113 | self.add_skip_color_PushButton.setObjectName("add_skip_color_PushButton") 114 | self.remove_skip_color_PushButton = QtWidgets.QPushButton(self.generalTab) 115 | self.remove_skip_color_PushButton.setGeometry(QtCore.QRect(270, 340, 81, 23)) 116 | self.remove_skip_color_PushButton.setObjectName("remove_skip_color_PushButton") 117 | self.label_48 = QtWidgets.QLabel(self.generalTab) 118 | self.label_48.setGeometry(QtCore.QRect(20, 290, 331, 21)) 119 | self.label_48.setObjectName("label_48") 120 | self.show_ctrl_PushButton = QtWidgets.QPushButton(self.generalTab) 121 | self.show_ctrl_PushButton.setGeometry(QtCore.QRect(240, 180, 101, 23)) 122 | self.show_ctrl_PushButton.setFocusPolicy(QtCore.Qt.StrongFocus) 123 | self.show_ctrl_PushButton.setDefault(False) 124 | self.show_ctrl_PushButton.setObjectName("show_ctrl_PushButton") 125 | self.available_colors_PushButton = QtWidgets.QPushButton(self.generalTab) 126 | self.available_colors_PushButton.setGeometry(QtCore.QRect(270, 370, 81, 51)) 127 | self.available_colors_PushButton.setObjectName("available_colors_PushButton") 128 | self.tabWidget.addTab(self.generalTab, "") 129 | self.paintingTab = QtWidgets.QWidget() 130 | self.paintingTab.setObjectName("paintingTab") 131 | self.pause_key_LineEdit = QtWidgets.QLineEdit(self.paintingTab) 132 | self.pause_key_LineEdit.setGeometry(QtCore.QRect(180, 20, 171, 20)) 133 | self.pause_key_LineEdit.setObjectName("pause_key_LineEdit") 134 | self.label_10 = QtWidgets.QLabel(self.paintingTab) 135 | self.label_10.setGeometry(QtCore.QRect(20, 20, 161, 21)) 136 | self.label_10.setObjectName("label_10") 137 | self.label_11 = QtWidgets.QLabel(self.paintingTab) 138 | self.label_11.setGeometry(QtCore.QRect(20, 50, 161, 21)) 139 | self.label_11.setObjectName("label_11") 140 | self.skip_key_LineEdit = QtWidgets.QLineEdit(self.paintingTab) 141 | self.skip_key_LineEdit.setGeometry(QtCore.QRect(180, 50, 171, 20)) 142 | self.skip_key_LineEdit.setObjectName("skip_key_LineEdit") 143 | self.label_12 = QtWidgets.QLabel(self.paintingTab) 144 | self.label_12.setGeometry(QtCore.QRect(20, 80, 161, 21)) 145 | self.label_12.setObjectName("label_12") 146 | self.abort_key_LineEdit = QtWidgets.QLineEdit(self.paintingTab) 147 | self.abort_key_LineEdit.setGeometry(QtCore.QRect(180, 80, 171, 20)) 148 | self.abort_key_LineEdit.setObjectName("abort_key_LineEdit") 149 | self.line_2 = QtWidgets.QFrame(self.paintingTab) 150 | self.line_2.setGeometry(QtCore.QRect(10, 110, 351, 20)) 151 | self.line_2.setFrameShape(QtWidgets.QFrame.HLine) 152 | self.line_2.setFrameShadow(QtWidgets.QFrame.Sunken) 153 | self.line_2.setObjectName("line_2") 154 | self.update_canvas_CheckBox = QtWidgets.QCheckBox(self.paintingTab) 155 | self.update_canvas_CheckBox.setGeometry(QtCore.QRect(20, 140, 341, 17)) 156 | self.update_canvas_CheckBox.setChecked(True) 157 | self.update_canvas_CheckBox.setObjectName("update_canvas_CheckBox") 158 | self.update_canvas_end_CheckBox = QtWidgets.QCheckBox(self.paintingTab) 159 | self.update_canvas_end_CheckBox.setGeometry(QtCore.QRect(20, 160, 341, 17)) 160 | self.update_canvas_end_CheckBox.setChecked(True) 161 | self.update_canvas_end_CheckBox.setObjectName("update_canvas_end_CheckBox") 162 | self.opacities_CheckBox = QtWidgets.QCheckBox(self.paintingTab) 163 | self.opacities_CheckBox.setGeometry(QtCore.QRect(20, 340, 341, 17)) 164 | self.opacities_CheckBox.setChecked(True) 165 | self.opacities_CheckBox.setObjectName("opacities_CheckBox") 166 | self.draw_lines_CheckBox = QtWidgets.QCheckBox(self.paintingTab) 167 | self.draw_lines_CheckBox.setGeometry(QtCore.QRect(20, 180, 341, 17)) 168 | self.draw_lines_CheckBox.setChecked(True) 169 | self.draw_lines_CheckBox.setObjectName("draw_lines_CheckBox") 170 | self.line_4 = QtWidgets.QFrame(self.paintingTab) 171 | self.line_4.setGeometry(QtCore.QRect(10, 310, 351, 20)) 172 | self.line_4.setFrameShape(QtWidgets.QFrame.HLine) 173 | self.line_4.setFrameShadow(QtWidgets.QFrame.Sunken) 174 | self.line_4.setObjectName("line_4") 175 | self.label_24 = QtWidgets.QLabel(self.paintingTab) 176 | self.label_24.setGeometry(QtCore.QRect(40, 370, 321, 41)) 177 | self.label_24.setObjectName("label_24") 178 | self.hidden_colors_CheckBox = QtWidgets.QCheckBox(self.paintingTab) 179 | self.hidden_colors_CheckBox.setGeometry(QtCore.QRect(20, 360, 341, 16)) 180 | self.hidden_colors_CheckBox.setObjectName("hidden_colors_CheckBox") 181 | self.show_info_CheckBox = QtWidgets.QCheckBox(self.paintingTab) 182 | self.show_info_CheckBox.setGeometry(QtCore.QRect(20, 200, 341, 17)) 183 | self.show_info_CheckBox.setChecked(True) 184 | self.show_info_CheckBox.setObjectName("show_info_CheckBox") 185 | self.show_preview_CheckBox = QtWidgets.QCheckBox(self.paintingTab) 186 | self.show_preview_CheckBox.setGeometry(QtCore.QRect(20, 220, 341, 31)) 187 | self.show_preview_CheckBox.setChecked(True) 188 | self.show_preview_CheckBox.setObjectName("show_preview_CheckBox") 189 | self.hide_preview_CheckBox = QtWidgets.QCheckBox(self.paintingTab) 190 | self.hide_preview_CheckBox.setGeometry(QtCore.QRect(20, 260, 341, 16)) 191 | self.hide_preview_CheckBox.setChecked(True) 192 | self.hide_preview_CheckBox.setObjectName("hide_preview_CheckBox") 193 | self.paint_background_CheckBox = QtWidgets.QCheckBox(self.paintingTab) 194 | self.paint_background_CheckBox.setGeometry(QtCore.QRect(20, 280, 341, 16)) 195 | self.paint_background_CheckBox.setObjectName("paint_background_CheckBox") 196 | self.tabWidget.addTab(self.paintingTab, "") 197 | self.experimentalTab = QtWidgets.QWidget() 198 | self.experimentalTab.setObjectName("experimentalTab") 199 | self.label_15 = QtWidgets.QLabel(self.experimentalTab) 200 | self.label_15.setGeometry(QtCore.QRect(20, 20, 161, 20)) 201 | self.label_15.setObjectName("label_15") 202 | self.label_19 = QtWidgets.QLabel(self.experimentalTab) 203 | self.label_19.setGeometry(QtCore.QRect(280, 20, 81, 20)) 204 | self.label_19.setObjectName("label_19") 205 | self.click_delay_LineEdit = QtWidgets.QLineEdit(self.experimentalTab) 206 | self.click_delay_LineEdit.setGeometry(QtCore.QRect(180, 20, 91, 20)) 207 | self.click_delay_LineEdit.setObjectName("click_delay_LineEdit") 208 | self.label_20 = QtWidgets.QLabel(self.experimentalTab) 209 | self.label_20.setGeometry(QtCore.QRect(280, 80, 81, 20)) 210 | self.label_20.setObjectName("label_20") 211 | self.label_16 = QtWidgets.QLabel(self.experimentalTab) 212 | self.label_16.setGeometry(QtCore.QRect(20, 80, 161, 20)) 213 | self.label_16.setObjectName("label_16") 214 | self.line_delay_LineEdit = QtWidgets.QLineEdit(self.experimentalTab) 215 | self.line_delay_LineEdit.setGeometry(QtCore.QRect(180, 80, 91, 20)) 216 | self.line_delay_LineEdit.setObjectName("line_delay_LineEdit") 217 | self.label_21 = QtWidgets.QLabel(self.experimentalTab) 218 | self.label_21.setGeometry(QtCore.QRect(280, 50, 81, 20)) 219 | self.label_21.setObjectName("label_21") 220 | self.label_22 = QtWidgets.QLabel(self.experimentalTab) 221 | self.label_22.setGeometry(QtCore.QRect(280, 110, 81, 20)) 222 | self.label_22.setObjectName("label_22") 223 | self.label_17 = QtWidgets.QLabel(self.experimentalTab) 224 | self.label_17.setGeometry(QtCore.QRect(20, 50, 161, 20)) 225 | self.label_17.setObjectName("label_17") 226 | self.label_18 = QtWidgets.QLabel(self.experimentalTab) 227 | self.label_18.setGeometry(QtCore.QRect(20, 110, 161, 20)) 228 | self.label_18.setObjectName("label_18") 229 | self.min_line_width_LineEdit = QtWidgets.QLineEdit(self.experimentalTab) 230 | self.min_line_width_LineEdit.setGeometry(QtCore.QRect(180, 110, 91, 20)) 231 | self.min_line_width_LineEdit.setObjectName("min_line_width_LineEdit") 232 | self.ctrl_delay_LineEdit = QtWidgets.QLineEdit(self.experimentalTab) 233 | self.ctrl_delay_LineEdit.setGeometry(QtCore.QRect(180, 50, 91, 20)) 234 | self.ctrl_delay_LineEdit.setObjectName("ctrl_delay_LineEdit") 235 | self.line_5 = QtWidgets.QFrame(self.experimentalTab) 236 | self.line_5.setGeometry(QtCore.QRect(10, 140, 351, 20)) 237 | self.line_5.setFrameShape(QtWidgets.QFrame.HLine) 238 | self.line_5.setFrameShadow(QtWidgets.QFrame.Sunken) 239 | self.line_5.setObjectName("line_5") 240 | self.brush_type_ComboBox = QtWidgets.QComboBox(self.experimentalTab) 241 | self.brush_type_ComboBox.setGeometry(QtCore.QRect(180, 170, 141, 22)) 242 | self.brush_type_ComboBox.setObjectName("brush_type_ComboBox") 243 | icon = QtGui.QIcon() 244 | icon.addPixmap(QtGui.QPixmap(":/brushes/light_round.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off) 245 | self.brush_type_ComboBox.addItem(icon, "") 246 | icon1 = QtGui.QIcon() 247 | icon1.addPixmap(QtGui.QPixmap(":/brushes/heavy_round.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off) 248 | self.brush_type_ComboBox.addItem(icon1, "") 249 | icon2 = QtGui.QIcon() 250 | icon2.addPixmap(QtGui.QPixmap(":/brushes/medium_round.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off) 251 | self.brush_type_ComboBox.addItem(icon2, "") 252 | icon3 = QtGui.QIcon() 253 | icon3.addPixmap(QtGui.QPixmap(":/brushes/heavy_square.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off) 254 | self.brush_type_ComboBox.addItem(icon3, "") 255 | self.label_23 = QtWidgets.QLabel(self.experimentalTab) 256 | self.label_23.setGeometry(QtCore.QRect(20, 170, 161, 21)) 257 | self.label_23.setObjectName("label_23") 258 | self.line_6 = QtWidgets.QFrame(self.experimentalTab) 259 | self.line_6.setGeometry(QtCore.QRect(10, 200, 351, 20)) 260 | self.line_6.setFrameShape(QtWidgets.QFrame.HLine) 261 | self.line_6.setFrameShadow(QtWidgets.QFrame.Sunken) 262 | self.line_6.setObjectName("line_6") 263 | self.double_click_CheckBox = QtWidgets.QCheckBox(self.experimentalTab) 264 | self.double_click_CheckBox.setGeometry(QtCore.QRect(20, 230, 341, 17)) 265 | self.double_click_CheckBox.setObjectName("double_click_CheckBox") 266 | self.click_color_PushButton = QtWidgets.QPushButton(self.experimentalTab) 267 | self.click_color_PushButton.setGeometry(QtCore.QRect(220, 390, 141, 31)) 268 | self.click_color_PushButton.setObjectName("click_color_PushButton") 269 | self.tabWidget.addTab(self.experimentalTab, "") 270 | self.aboutTab = QtWidgets.QWidget() 271 | self.aboutTab.setObjectName("aboutTab") 272 | self.gitRepoLinkLabel = QtWidgets.QLabel(self.aboutTab) 273 | self.gitRepoLinkLabel.setGeometry(QtCore.QRect(20, 340, 221, 16)) 274 | self.gitRepoLinkLabel.setTextFormat(QtCore.Qt.RichText) 275 | self.gitRepoLinkLabel.setScaledContents(False) 276 | self.gitRepoLinkLabel.setAlignment(QtCore.Qt.AlignLeading|QtCore.Qt.AlignLeft|QtCore.Qt.AlignVCenter) 277 | self.gitRepoLinkLabel.setOpenExternalLinks(True) 278 | self.gitRepoLinkLabel.setTextInteractionFlags(QtCore.Qt.TextBrowserInteraction) 279 | self.gitRepoLinkLabel.setObjectName("gitRepoLinkLabel") 280 | self.logo1Label = QtWidgets.QLabel(self.aboutTab) 281 | self.logo1Label.setGeometry(QtCore.QRect(10, 30, 351, 71)) 282 | self.logo1Label.setText("") 283 | self.logo1Label.setPixmap(QtGui.QPixmap(":/icons/RustDaVinci-logo-2.png")) 284 | self.logo1Label.setScaledContents(True) 285 | self.logo1Label.setObjectName("logo1Label") 286 | self.aboutLabel = QtWidgets.QLabel(self.aboutTab) 287 | self.aboutLabel.setGeometry(QtCore.QRect(20, 160, 331, 101)) 288 | self.aboutLabel.setWordWrap(True) 289 | self.aboutLabel.setObjectName("aboutLabel") 290 | self.versionLabel = QtWidgets.QLabel(self.aboutTab) 291 | self.versionLabel.setGeometry(QtCore.QRect(20, 110, 161, 20)) 292 | self.versionLabel.setObjectName("versionLabel") 293 | self.versionLabel_2 = QtWidgets.QLabel(self.aboutTab) 294 | self.versionLabel_2.setGeometry(QtCore.QRect(20, 130, 161, 20)) 295 | self.versionLabel_2.setObjectName("versionLabel_2") 296 | self.licenseLabel = QtWidgets.QLabel(self.aboutTab) 297 | self.licenseLabel.setGeometry(QtCore.QRect(20, 270, 311, 31)) 298 | self.licenseLabel.setWordWrap(True) 299 | self.licenseLabel.setObjectName("licenseLabel") 300 | self.line = QtWidgets.QFrame(self.aboutTab) 301 | self.line.setGeometry(QtCore.QRect(10, 310, 351, 20)) 302 | self.line.setFrameShape(QtWidgets.QFrame.HLine) 303 | self.line.setFrameShadow(QtWidgets.QFrame.Sunken) 304 | self.line.setObjectName("line") 305 | self.logo2Label = QtWidgets.QLabel(self.aboutTab) 306 | self.logo2Label.setGeometry(QtCore.QRect(250, 340, 81, 81)) 307 | self.logo2Label.setText("") 308 | self.logo2Label.setPixmap(QtGui.QPixmap(":/icons/RustDaVinci-logo-1.png")) 309 | self.logo2Label.setScaledContents(True) 310 | self.logo2Label.setObjectName("logo2Label") 311 | self.faqLinkLabel_2 = QtWidgets.QLabel(self.aboutTab) 312 | self.faqLinkLabel_2.setGeometry(QtCore.QRect(20, 360, 221, 16)) 313 | self.faqLinkLabel_2.setTextFormat(QtCore.Qt.RichText) 314 | self.faqLinkLabel_2.setScaledContents(False) 315 | self.faqLinkLabel_2.setAlignment(QtCore.Qt.AlignLeading|QtCore.Qt.AlignLeft|QtCore.Qt.AlignVCenter) 316 | self.faqLinkLabel_2.setOpenExternalLinks(True) 317 | self.faqLinkLabel_2.setTextInteractionFlags(QtCore.Qt.TextBrowserInteraction) 318 | self.faqLinkLabel_2.setObjectName("faqLinkLabel_2") 319 | self.tabWidget.addTab(self.aboutTab, "") 320 | self.default_PushButton = QtWidgets.QPushButton(SettingsUI) 321 | self.default_PushButton.setGeometry(QtCore.QRect(10, 480, 75, 23)) 322 | self.default_PushButton.setObjectName("default_PushButton") 323 | self.ok_PushButton = QtWidgets.QPushButton(SettingsUI) 324 | self.ok_PushButton.setGeometry(QtCore.QRect(150, 480, 75, 23)) 325 | self.ok_PushButton.setFocusPolicy(QtCore.Qt.StrongFocus) 326 | self.ok_PushButton.setDefault(True) 327 | self.ok_PushButton.setObjectName("ok_PushButton") 328 | self.cancel_PushButton = QtWidgets.QPushButton(SettingsUI) 329 | self.cancel_PushButton.setGeometry(QtCore.QRect(230, 480, 75, 23)) 330 | self.cancel_PushButton.setObjectName("cancel_PushButton") 331 | self.apply_PushButton = QtWidgets.QPushButton(SettingsUI) 332 | self.apply_PushButton.setEnabled(False) 333 | self.apply_PushButton.setGeometry(QtCore.QRect(310, 480, 75, 23)) 334 | self.apply_PushButton.setObjectName("apply_PushButton") 335 | 336 | self.retranslateUi(SettingsUI) 337 | self.tabWidget.setCurrentIndex(0) 338 | self.quality_ComboBox.setCurrentIndex(0) 339 | self.brush_type_ComboBox.setCurrentIndex(1) 340 | QtCore.QMetaObject.connectSlotsByName(SettingsUI) 341 | 342 | def retranslateUi(self, SettingsUI): 343 | _translate = QtCore.QCoreApplication.translate 344 | SettingsUI.setWindowTitle(_translate("SettingsUI", "RustDaVinci Settings")) 345 | self.quality_ComboBox.setToolTip(_translate("SettingsUI", "The painting quality")) 346 | self.quality_ComboBox.setCurrentText(_translate("SettingsUI", "Normal")) 347 | self.quality_ComboBox.setItemText(0, _translate("SettingsUI", "Normal")) 348 | self.quality_ComboBox.setItemText(1, _translate("SettingsUI", "High")) 349 | self.label_1.setText(_translate("SettingsUI", "Painting Quality:")) 350 | self.label_4.setText(_translate("SettingsUI", "Control area width:")) 351 | self.label_7.setText(_translate("SettingsUI", "(in pixels)")) 352 | self.label_9.setText(_translate("SettingsUI", "(in pixels)")) 353 | self.ctrl_y_LineEdit.setToolTip(_translate("SettingsUI", "The y-coordinate for the topleft corner of the painting control area")) 354 | self.ctrl_y_LineEdit.setText(_translate("SettingsUI", "0")) 355 | self.clear_coords_PushButton.setToolTip(_translate("SettingsUI", "Clear the painting controls area coordinates & ratio")) 356 | self.clear_coords_PushButton.setText(_translate("SettingsUI", "Clear Coordinates")) 357 | self.ctrl_h_LineEdit.setToolTip(_translate("SettingsUI", "The height of the painting control area")) 358 | self.ctrl_h_LineEdit.setText(_translate("SettingsUI", "0")) 359 | self.ctrl_w_LineEdit.setToolTip(_translate("SettingsUI", "The width of the painting control area")) 360 | self.ctrl_w_LineEdit.setText(_translate("SettingsUI", "0")) 361 | self.label_2.setText(_translate("SettingsUI", "Control area x-coordinate:")) 362 | self.label_8.setText(_translate("SettingsUI", "(in pixels)")) 363 | self.label_6.setText(_translate("SettingsUI", "(in pixels)")) 364 | self.ctrl_x_LineEdit.setToolTip(_translate("SettingsUI", "The x-coordinate for the topleft corner of the painting control area")) 365 | self.ctrl_x_LineEdit.setText(_translate("SettingsUI", "0")) 366 | self.label_5.setText(_translate("SettingsUI", "Control area height:")) 367 | self.label_3.setText(_translate("SettingsUI", "Control area y-coordinate:")) 368 | self.topmost_CheckBox.setToolTip(_translate("SettingsUI", "This will set RustDaVinci app topmost property to true and will appear above all windows while painting")) 369 | self.topmost_CheckBox.setText(_translate("SettingsUI", "Set the RustDaVinci window on topmost while painting")) 370 | self.skip_background_CheckBox.setToolTip(_translate("SettingsUI", "This will ignore painting the set default background color")) 371 | self.skip_background_CheckBox.setText(_translate("SettingsUI", "Skip painting the default background color")) 372 | self.label_13.setText(_translate("SettingsUI", "Default background color:")) 373 | self.color_picker_PushButton.setToolTip(_translate("SettingsUI", "Use the color finder")) 374 | self.color_picker_PushButton.setText(_translate("SettingsUI", "...")) 375 | self.background_LineEdit.setToolTip(_translate("SettingsUI", "This is the set default background HEX color")) 376 | self.background_LineEdit.setText(_translate("SettingsUI", "#ECF0F1")) 377 | self.skip_colors_ListWidget.setToolTip(_translate("SettingsUI", "A list full of the colors that will be ignored when painting")) 378 | self.add_skip_color_PushButton.setToolTip(_translate("SettingsUI", "Add colors to the list of colors to ignore when painting")) 379 | self.add_skip_color_PushButton.setText(_translate("SettingsUI", "Add")) 380 | self.remove_skip_color_PushButton.setToolTip(_translate("SettingsUI", "Remove selected color from the colors to ignore when painting")) 381 | self.remove_skip_color_PushButton.setText(_translate("SettingsUI", "Remove")) 382 | self.label_48.setText(_translate("SettingsUI", "Skip painting these colors:")) 383 | self.show_ctrl_PushButton.setToolTip(_translate("SettingsUI", "Show where on the screen the painting controls area is located according to the coordinates & ratio")) 384 | self.show_ctrl_PushButton.setText(_translate("SettingsUI", "Show Controls")) 385 | self.available_colors_PushButton.setToolTip(_translate("SettingsUI", "Opens a dialog window showing all the possible colors in RustDaVinci")) 386 | self.available_colors_PushButton.setText(_translate("SettingsUI", "Available\n" 387 | "Colors")) 388 | self.tabWidget.setTabText(self.tabWidget.indexOf(self.generalTab), _translate("SettingsUI", "General")) 389 | self.pause_key_LineEdit.setToolTip(_translate("SettingsUI", "This is the hotkey for pausing and resumeing the painting process")) 390 | self.pause_key_LineEdit.setText(_translate("SettingsUI", "f10")) 391 | self.label_10.setText(_translate("SettingsUI", "Pause Hotkey:")) 392 | self.label_11.setText(_translate("SettingsUI", "Skip Color Hotkey:")) 393 | self.skip_key_LineEdit.setToolTip(_translate("SettingsUI", "This is the hotkey for skipping the current color being painted")) 394 | self.skip_key_LineEdit.setText(_translate("SettingsUI", "f11")) 395 | self.label_12.setText(_translate("SettingsUI", "Abort Hotkey:")) 396 | self.abort_key_LineEdit.setToolTip(_translate("SettingsUI", "This is the hotkey for aborting the painting process")) 397 | self.abort_key_LineEdit.setText(_translate("SettingsUI", "esc")) 398 | self.update_canvas_CheckBox.setToolTip(_translate("SettingsUI", "This will automatically update the canvas when switching a color while painting")) 399 | self.update_canvas_CheckBox.setText(_translate("SettingsUI", "Automatically update the canvas while painting")) 400 | self.update_canvas_end_CheckBox.setToolTip(_translate("SettingsUI", "This will automatically update the canvas when the painting process is completed")) 401 | self.update_canvas_end_CheckBox.setText(_translate("SettingsUI", "Automatically save the painting when completed")) 402 | self.opacities_CheckBox.setToolTip(_translate("SettingsUI", "This will improve paintings by utilizing different brush opacities")) 403 | self.opacities_CheckBox.setText(_translate("SettingsUI", "Improve paintings by utilizing different brush opacities")) 404 | self.draw_lines_CheckBox.setToolTip(_translate("SettingsUI", "This causes grouped pixels to be drawn as a line instead of painting each pixel (speeds up painting)")) 405 | self.draw_lines_CheckBox.setText(_translate("SettingsUI", "Draw lines if calculated to be faster")) 406 | self.label_24.setText(_translate("SettingsUI", "(Only recommended if 1920x1080 resolution in-game and \n" 407 | "the paint control area is automatically found)")) 408 | self.hidden_colors_CheckBox.setToolTip(_translate("SettingsUI", "This will improve paintings by utilizing hidden colors (colors hidden between the visible color circles)")) 409 | self.hidden_colors_CheckBox.setText(_translate("SettingsUI", "Use the hidden color palette")) 410 | self.show_info_CheckBox.setToolTip(_translate("SettingsUI", "This will display painting information such as colors, total pixels and lines before the painting process starts")) 411 | self.show_info_CheckBox.setText(_translate("SettingsUI", "Show painting information before starting the painting")) 412 | self.show_preview_CheckBox.setToolTip(_translate("SettingsUI", "This will automatically show the preview based on the quality setting when loading a new image")) 413 | self.show_preview_CheckBox.setText(_translate("SettingsUI", "Automatically show painting preview based on the quality setting\n" 414 | "when loading new image")) 415 | self.hide_preview_CheckBox.setToolTip(_translate("SettingsUI", "This will automatically hide the preview when the painting process starts")) 416 | self.hide_preview_CheckBox.setText(_translate("SettingsUI", "Automatically hide painting preview before painting starts")) 417 | self.paint_background_CheckBox.setToolTip(_translate("SettingsUI", "This will automatically paint the background with the set background color before the painting process begins")) 418 | self.paint_background_CheckBox.setText(_translate("SettingsUI", "Automatically paint the background at start")) 419 | self.tabWidget.setTabText(self.tabWidget.indexOf(self.paintingTab), _translate("SettingsUI", "Painting")) 420 | self.label_15.setText(_translate("SettingsUI", "Mouse-click delay:")) 421 | self.label_19.setText(_translate("SettingsUI", "(in milliseconds)")) 422 | self.click_delay_LineEdit.setToolTip(_translate("SettingsUI", "This is the delay when releasing the mouse button during a click event. Increasing this improves painting accuracy at the cost of speed.")) 423 | self.click_delay_LineEdit.setText(_translate("SettingsUI", "15")) 424 | self.label_20.setText(_translate("SettingsUI", "(in milliseconds)")) 425 | self.label_16.setText(_translate("SettingsUI", "Line-draw delay:")) 426 | self.line_delay_LineEdit.setToolTip(_translate("SettingsUI", "This is the delay when painting a line. Increasing this improves painting accuracy at the cost of speed.")) 427 | self.line_delay_LineEdit.setText(_translate("SettingsUI", "25")) 428 | self.label_21.setText(_translate("SettingsUI", "(in milliseconds)")) 429 | self.label_22.setText(_translate("SettingsUI", "(in pixels)")) 430 | self.label_17.setText(_translate("SettingsUI", "Control area delay:")) 431 | self.label_18.setText(_translate("SettingsUI", "Minimum line width:")) 432 | self.min_line_width_LineEdit.setToolTip(_translate("SettingsUI", "This is the minimum of grouped pixels requred before drawing a line. Changing this may affect the overall painting time.")) 433 | self.min_line_width_LineEdit.setText(_translate("SettingsUI", "10")) 434 | self.ctrl_delay_LineEdit.setToolTip(_translate("SettingsUI", "This is the delay between the clicks on different painting controls")) 435 | self.ctrl_delay_LineEdit.setText(_translate("SettingsUI", "150")) 436 | self.brush_type_ComboBox.setToolTip(_translate("SettingsUI", "The default brush type used for painting")) 437 | self.brush_type_ComboBox.setCurrentText(_translate("SettingsUI", "Heavy Round")) 438 | self.brush_type_ComboBox.setItemText(0, _translate("SettingsUI", "Light Round")) 439 | self.brush_type_ComboBox.setItemText(1, _translate("SettingsUI", "Heavy Round")) 440 | self.brush_type_ComboBox.setItemText(2, _translate("SettingsUI", "Medium Round")) 441 | self.brush_type_ComboBox.setItemText(3, _translate("SettingsUI", "Heavy Square")) 442 | self.label_23.setText(_translate("SettingsUI", "Painting brush type:")) 443 | self.double_click_CheckBox.setToolTip(_translate("SettingsUI", "This will automatically click the mouse button twice during the painting process eliminating any dead pixels")) 444 | self.double_click_CheckBox.setText(_translate("SettingsUI", "Double-click the mouse for improved painting accuracy")) 445 | self.click_color_PushButton.setToolTip(_translate("SettingsUI", "Opens a dialog where you can select a color that the application will click in the in-game palette")) 446 | self.click_color_PushButton.setText(_translate("SettingsUI", "Click Color")) 447 | self.tabWidget.setTabText(self.tabWidget.indexOf(self.experimentalTab), _translate("SettingsUI", "Experimental")) 448 | self.gitRepoLinkLabel.setToolTip(_translate("SettingsUI", "https://github.com/alexemanuelol/RustDaVinci")) 449 | self.gitRepoLinkLabel.setText(_translate("SettingsUI", "

The GitHub Repository

")) 450 | self.aboutLabel.setText(_translate("SettingsUI", "RustDaVinci is an automatic sign painter for the game Rust by Facepunch. The application is completely free and open-source. For those who would like to contribute to the application please visit the GitHub page in the link below. For those who just want to use the application as it is, it is strongly recommended to only use the released version of the application to avoid trouble with EAC/ Facepunch. The latest releases can be found on the Github page.")) 451 | self.versionLabel.setText(_translate("SettingsUI", "v0.4.0")) 452 | self.versionLabel_2.setText(_translate("SettingsUI", "March 6, 2020")) 453 | self.licenseLabel.setText(_translate("SettingsUI", "RustDaVinci is licensed under GNU GPL3\n" 454 | "Developed by AlexEmanuelol")) 455 | self.faqLinkLabel_2.setToolTip(_translate("SettingsUI", "https://github.com/alexemanuelol/RustDaVinci/blob/master/docs/FAQ.md")) 456 | self.faqLinkLabel_2.setText(_translate("SettingsUI", "

Frequently Asked Questions

")) 457 | self.tabWidget.setTabText(self.tabWidget.indexOf(self.aboutTab), _translate("SettingsUI", "About")) 458 | self.default_PushButton.setToolTip(_translate("SettingsUI", "Revert all settings to their default value")) 459 | self.default_PushButton.setText(_translate("SettingsUI", "Defaults")) 460 | self.ok_PushButton.setText(_translate("SettingsUI", "OK")) 461 | self.cancel_PushButton.setText(_translate("SettingsUI", "Cancel")) 462 | self.apply_PushButton.setText(_translate("SettingsUI", "Apply")) 463 | import ui.resources.icons_rc 464 | -------------------------------------------------------------------------------- /rustdavinci/ui/views/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alexemanuelol/rustdavinci/89c749f78b4922383acc70b503e1e68a50c02f5f/rustdavinci/ui/views/__init__.py -------------------------------------------------------------------------------- /rustdavinci/ui/views/convert_ui.py: -------------------------------------------------------------------------------- 1 | import subprocess 2 | 3 | subprocess.run("pyuic5 mainui.ui -o mainui.py") 4 | 5 | s = open("mainui.py").read() 6 | s = s.replace("import icons_rc", "import ui.resources.icons_rc") 7 | f = open("mainui.py", "w") 8 | f.write(s) 9 | f.close() 10 | -------------------------------------------------------------------------------- /rustdavinci/ui/views/main.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | 4 | from PyQt5.QtCore import QRect, QSettings, QSize, Qt 5 | from PyQt5.QtGui import QPixmap 6 | from PyQt5.QtWidgets import QMenu, QLabel, QFrame, QMainWindow, QMenu, QPushButton 7 | 8 | from PIL import Image 9 | from PIL.ImageQt import ImageQt 10 | 11 | from ui.settings.settings import Settings 12 | from ui.views.mainui import Ui_MainUI 13 | from lib.rustDaVinci import rustDaVinci 14 | import ui.resources.icons_rc 15 | 16 | class MainWindow(QMainWindow): 17 | 18 | def __init__(self, parent=None): 19 | """ Main window init """ 20 | super(MainWindow, self).__init__(parent) 21 | 22 | # Setup UI 23 | self.ui = Ui_MainUI() 24 | self.ui.setupUi(self) 25 | 26 | # Setup settings object 27 | self.settings = QSettings() 28 | 29 | # Setup rustDaVinci object 30 | self.rustDaVinci = rustDaVinci(self) 31 | 32 | # Clear Image action 33 | self.action_clearImage = None 34 | 35 | # Connect UI modules 36 | self.connectAll() 37 | 38 | # Update the rustDaVinci module 39 | self.rustDaVinci.update() 40 | 41 | self.is_expanded = False 42 | self.label = None 43 | 44 | 45 | def connectAll(self): 46 | """ Connect all the buttons """ 47 | # Add actions to the loadImagePushButton 48 | loadMenu = QMenu() 49 | loadMenu.addAction("From File...", self.load_image_file_clicked) 50 | loadMenu.addAction("From URL...", self.load_image_URL_clicked) 51 | self.action_clearImage = loadMenu.addAction("Clear image", self.clear_image_clicked) 52 | self.action_clearImage.setEnabled(False) 53 | self.ui.load_image_PushButton.setMenu(loadMenu) 54 | 55 | # Add actions to the identifyAreasPushButton 56 | identifyMenu = QMenu() 57 | identifyMenu.addAction("Manually", self.locate_ctrl_manually_clicked) 58 | identifyMenu.addAction("Automatically", self.locate_ctrl_automatically_clicked) 59 | self.ui.identify_ctrl_PushButton.setMenu(identifyMenu) 60 | 61 | self.ui.paint_image_PushButton.clicked.connect(self.paint_image_clicked) 62 | self.ui.settings_PushButton.clicked.connect(self.settings_clicked) 63 | 64 | self.ui.preview_PushButton.clicked.connect(self.preview_clicked) 65 | 66 | 67 | def load_image_file_clicked(self): 68 | """ Load image from file """ 69 | self.rustDaVinci.load_image_from_file() 70 | if self.rustDaVinci.org_img != None: 71 | self.action_clearImage.setEnabled(True) 72 | self.ui.preview_PushButton.setEnabled(True) 73 | if self.is_expanded: 74 | self.label.hide() 75 | self.expand_window() 76 | 77 | 78 | def load_image_URL_clicked(self): 79 | """ Load image from URL """ 80 | self.rustDaVinci.load_image_from_url() 81 | if self.rustDaVinci.org_img != None: 82 | self.action_clearImage.setEnabled(True) 83 | self.ui.preview_PushButton.setEnabled(True) 84 | if self.is_expanded: 85 | self.label.hide() 86 | self.expand_window() 87 | 88 | 89 | def clear_image_clicked(self): 90 | """ Clear the current image """ 91 | self.rustDaVinci.clear_image() 92 | self.action_clearImage.setEnabled(False) 93 | self.ui.preview_PushButton.setEnabled(False) 94 | self.ui.paint_image_PushButton.setEnabled(False) 95 | self.is_expanded = True 96 | self.preview_clicked() 97 | 98 | 99 | def locate_ctrl_manually_clicked(self): 100 | """ Locate the control area coordinates manually """ 101 | self.rustDaVinci.locate_control_area_manually() 102 | 103 | 104 | def locate_ctrl_automatically_clicked(self): 105 | """ Locate the control area coordinates automatically """ 106 | self.rustDaVinci.locate_control_area_automatically() 107 | 108 | 109 | def paint_image_clicked(self): 110 | """ Start the painting process """ 111 | self.rustDaVinci.start_painting() 112 | 113 | 114 | def settings_clicked(self): 115 | """ Create an instance of a settings window """ 116 | settings = Settings(self) 117 | settings.exec_() 118 | 119 | 120 | def preview_clicked(self): 121 | """ Expand the main window and create image object """ 122 | if self.is_expanded: 123 | self.ui.preview_PushButton.setText("Show Image >>") 124 | self.is_expanded = False 125 | self.setMinimumSize(QSize(240, 450)) 126 | self.setMaximumSize(QSize(240, 450)) 127 | self.resize(240, 450) 128 | if self.label != None: 129 | self.label.hide() 130 | self.show_original_PushButton.hide() 131 | self.show_normal_PushButton.hide() 132 | self.show_high_PushButton.hide() 133 | else: 134 | self.expand_window() 135 | 136 | 137 | def expand_window(self): 138 | """ Expand the mainwindow to show preview images """ 139 | self.is_expanded = True 140 | 141 | self.ui.preview_PushButton.setText("<< Hide Image") 142 | 143 | self.setMinimumSize(QSize(800, 450)) 144 | self.setMaximumSize(QSize(800, 450)) 145 | self.resize(800, 450) 146 | 147 | self.label = QLabel(self) 148 | self.label.setGeometry(QRect(240, 10, 550, 380)) 149 | self.label.setFrameShape(QFrame.Panel) 150 | self.label.setLineWidth(1) 151 | self.label.show() 152 | 153 | if self.rustDaVinci.pixmap_on_display == 0: 154 | pixmap = self.rustDaVinci.org_img_pixmap 155 | elif self.rustDaVinci.pixmap_on_display == 1: 156 | pixmap = self.rustDaVinci.quantized_img_pixmap_normal 157 | elif self.rustDaVinci.pixmap_on_display == 2: 158 | pixmap = self.rustDaVinci.quantized_img_pixmap_high 159 | 160 | pixmap = pixmap.scaled(550, 380, Qt.KeepAspectRatio) 161 | self.label.setAlignment(Qt.AlignCenter) 162 | self.label.setPixmap(pixmap) 163 | 164 | self.show_original_PushButton = QPushButton("Original", self) 165 | self.show_original_PushButton.setGeometry(QRect(240, 400, 180, 21)) 166 | self.show_original_PushButton.show() 167 | self.show_original_PushButton.clicked.connect(self.show_original_pixmap) 168 | 169 | self.show_normal_PushButton = QPushButton("Normal", self) 170 | self.show_normal_PushButton.setGeometry(QRect(425, 400, 180, 21)) 171 | self.show_normal_PushButton.show() 172 | self.show_normal_PushButton.clicked.connect(self.show_normal_pixmap) 173 | 174 | self.show_high_PushButton = QPushButton("High", self) 175 | self.show_high_PushButton.setGeometry(QRect(610, 400, 180, 21)) 176 | self.show_high_PushButton.show() 177 | self.show_high_PushButton.clicked.connect(self.show_high_pixmap) 178 | 179 | 180 | def show_original_pixmap(self): 181 | """ Show the original quality pixmap""" 182 | self.rustDaVinci.pixmap_on_display = 0 183 | self.label.hide() 184 | self.show_original_PushButton.hide() 185 | self.show_normal_PushButton.hide() 186 | self.show_high_PushButton.hide() 187 | self.expand_window() 188 | 189 | 190 | def show_normal_pixmap(self): 191 | """ Show the normal quality pixmap""" 192 | self.rustDaVinci.pixmap_on_display = 1 193 | self.label.hide() 194 | self.show_original_PushButton.hide() 195 | self.show_normal_PushButton.hide() 196 | self.show_high_PushButton.hide() 197 | self.expand_window() 198 | 199 | 200 | def show_high_pixmap(self): 201 | """ Show the high quality pixmap """ 202 | self.rustDaVinci.pixmap_on_display = 2 203 | self.label.hide() 204 | self.show_original_PushButton.hide() 205 | self.show_normal_PushButton.hide() 206 | self.show_high_PushButton.hide() 207 | self.expand_window() 208 | 209 | 210 | def show(self): 211 | """ Show the main window """ 212 | super(MainWindow, self).show() 213 | 214 | 215 | def hide(self): 216 | """ Hide the main window """ 217 | super(MainWindow, self).hide() 218 | -------------------------------------------------------------------------------- /rustdavinci/ui/views/mainui.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | # Form implementation generated from reading ui file 'mainui.ui' 4 | # 5 | # Created by: PyQt5 UI code generator 5.13.0 6 | # 7 | # WARNING! All changes made in this file will be lost! 8 | 9 | 10 | from PyQt5 import QtCore, QtGui, QtWidgets 11 | 12 | 13 | class Ui_MainUI(object): 14 | def setupUi(self, MainUI): 15 | MainUI.setObjectName("MainUI") 16 | MainUI.resize(240, 450) 17 | MainUI.setMinimumSize(QtCore.QSize(240, 450)) 18 | MainUI.setMaximumSize(QtCore.QSize(240, 450)) 19 | icon = QtGui.QIcon() 20 | icon.addPixmap(QtGui.QPixmap(":/icons/RustDaVinci-icon.ico"), QtGui.QIcon.Normal, QtGui.QIcon.Off) 21 | MainUI.setWindowIcon(icon) 22 | self.centralwidget = QtWidgets.QWidget(MainUI) 23 | self.centralwidget.setObjectName("centralwidget") 24 | self.load_image_PushButton = QtWidgets.QPushButton(self.centralwidget) 25 | self.load_image_PushButton.setGeometry(QtCore.QRect(10, 10, 220, 45)) 26 | font = QtGui.QFont() 27 | font.setPointSize(10) 28 | font.setBold(True) 29 | font.setUnderline(False) 30 | font.setWeight(75) 31 | font.setStrikeOut(False) 32 | font.setKerning(True) 33 | self.load_image_PushButton.setFont(font) 34 | self.load_image_PushButton.setMouseTracking(False) 35 | self.load_image_PushButton.setTabletTracking(False) 36 | self.load_image_PushButton.setFocusPolicy(QtCore.Qt.StrongFocus) 37 | self.load_image_PushButton.setContextMenuPolicy(QtCore.Qt.DefaultContextMenu) 38 | self.load_image_PushButton.setAcceptDrops(False) 39 | self.load_image_PushButton.setToolTipDuration(-1) 40 | self.load_image_PushButton.setLayoutDirection(QtCore.Qt.LeftToRight) 41 | self.load_image_PushButton.setAutoFillBackground(False) 42 | self.load_image_PushButton.setStyleSheet("") 43 | self.load_image_PushButton.setInputMethodHints(QtCore.Qt.ImhNone) 44 | icon1 = QtGui.QIcon() 45 | icon1.addPixmap(QtGui.QPixmap(":/icons/load_image_icon.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off) 46 | self.load_image_PushButton.setIcon(icon1) 47 | self.load_image_PushButton.setIconSize(QtCore.QSize(220, 45)) 48 | self.load_image_PushButton.setCheckable(False) 49 | self.load_image_PushButton.setAutoDefault(False) 50 | self.load_image_PushButton.setDefault(False) 51 | self.load_image_PushButton.setFlat(True) 52 | self.load_image_PushButton.setObjectName("load_image_PushButton") 53 | self.identify_ctrl_PushButton = QtWidgets.QPushButton(self.centralwidget) 54 | self.identify_ctrl_PushButton.setGeometry(QtCore.QRect(10, 60, 220, 45)) 55 | font = QtGui.QFont() 56 | font.setPointSize(10) 57 | font.setBold(True) 58 | font.setUnderline(False) 59 | font.setWeight(75) 60 | font.setStrikeOut(False) 61 | self.identify_ctrl_PushButton.setFont(font) 62 | icon2 = QtGui.QIcon() 63 | icon2.addPixmap(QtGui.QPixmap(":/icons/select_area_icon.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off) 64 | self.identify_ctrl_PushButton.setIcon(icon2) 65 | self.identify_ctrl_PushButton.setIconSize(QtCore.QSize(220, 45)) 66 | self.identify_ctrl_PushButton.setFlat(True) 67 | self.identify_ctrl_PushButton.setObjectName("identify_ctrl_PushButton") 68 | self.paint_image_PushButton = QtWidgets.QPushButton(self.centralwidget) 69 | self.paint_image_PushButton.setEnabled(False) 70 | self.paint_image_PushButton.setGeometry(QtCore.QRect(10, 110, 220, 45)) 71 | font = QtGui.QFont() 72 | font.setPointSize(10) 73 | font.setBold(True) 74 | font.setUnderline(False) 75 | font.setWeight(75) 76 | self.paint_image_PushButton.setFont(font) 77 | self.paint_image_PushButton.setInputMethodHints(QtCore.Qt.ImhNone) 78 | icon3 = QtGui.QIcon() 79 | icon3.addPixmap(QtGui.QPixmap(":/icons/paint_image_icon.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off) 80 | self.paint_image_PushButton.setIcon(icon3) 81 | self.paint_image_PushButton.setIconSize(QtCore.QSize(220, 45)) 82 | self.paint_image_PushButton.setFlat(True) 83 | self.paint_image_PushButton.setObjectName("paint_image_PushButton") 84 | self.settings_PushButton = QtWidgets.QPushButton(self.centralwidget) 85 | self.settings_PushButton.setGeometry(QtCore.QRect(10, 160, 220, 45)) 86 | font = QtGui.QFont() 87 | font.setPointSize(10) 88 | font.setBold(True) 89 | font.setUnderline(False) 90 | font.setWeight(75) 91 | self.settings_PushButton.setFont(font) 92 | icon4 = QtGui.QIcon() 93 | icon4.addPixmap(QtGui.QPixmap(":/icons/settings_icon.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off) 94 | self.settings_PushButton.setIcon(icon4) 95 | self.settings_PushButton.setIconSize(QtCore.QSize(220, 45)) 96 | self.settings_PushButton.setFlat(True) 97 | self.settings_PushButton.setObjectName("settings_PushButton") 98 | self.line = QtWidgets.QFrame(self.centralwidget) 99 | self.line.setGeometry(QtCore.QRect(17, 220, 201, 16)) 100 | self.line.setFrameShape(QtWidgets.QFrame.HLine) 101 | self.line.setFrameShadow(QtWidgets.QFrame.Sunken) 102 | self.line.setObjectName("line") 103 | self.preview_PushButton = QtWidgets.QPushButton(self.centralwidget) 104 | self.preview_PushButton.setEnabled(False) 105 | self.preview_PushButton.setGeometry(QtCore.QRect(10, 350, 221, 41)) 106 | self.preview_PushButton.setObjectName("preview_PushButton") 107 | self.progress_ProgressBar = QtWidgets.QProgressBar(self.centralwidget) 108 | self.progress_ProgressBar.setGeometry(QtCore.QRect(10, 400, 221, 21)) 109 | self.progress_ProgressBar.setProperty("value", 0) 110 | self.progress_ProgressBar.setTextVisible(False) 111 | self.progress_ProgressBar.setOrientation(QtCore.Qt.Horizontal) 112 | self.progress_ProgressBar.setInvertedAppearance(False) 113 | self.progress_ProgressBar.setObjectName("progress_ProgressBar") 114 | self.log_TextEdit = QtWidgets.QTextEdit(self.centralwidget) 115 | self.log_TextEdit.setGeometry(QtCore.QRect(10, 240, 221, 101)) 116 | self.log_TextEdit.setUndoRedoEnabled(False) 117 | self.log_TextEdit.setReadOnly(True) 118 | self.log_TextEdit.setTextInteractionFlags(QtCore.Qt.NoTextInteraction) 119 | self.log_TextEdit.setObjectName("log_TextEdit") 120 | MainUI.setCentralWidget(self.centralwidget) 121 | self.statusbar = QtWidgets.QStatusBar(MainUI) 122 | self.statusbar.setObjectName("statusbar") 123 | MainUI.setStatusBar(self.statusbar) 124 | 125 | self.retranslateUi(MainUI) 126 | QtCore.QMetaObject.connectSlotsByName(MainUI) 127 | 128 | def retranslateUi(self, MainUI): 129 | _translate = QtCore.QCoreApplication.translate 130 | MainUI.setWindowTitle(_translate("MainUI", "RustDaVinci")) 131 | self.load_image_PushButton.setToolTip(_translate("MainUI", "Load Image from File or URL")) 132 | self.load_image_PushButton.setText(_translate("MainUI", " Load Image... ")) 133 | self.identify_ctrl_PushButton.setToolTip(_translate("MainUI", "Capture the painting control area manually or automatically")) 134 | self.identify_ctrl_PushButton.setText(_translate("MainUI", " Capture Control Area...")) 135 | self.paint_image_PushButton.setToolTip(_translate("MainUI", "Paint the Image")) 136 | self.paint_image_PushButton.setText(_translate("MainUI", " Paint Image ")) 137 | self.settings_PushButton.setToolTip(_translate("MainUI", "Show RustDaVinci Settings")) 138 | self.settings_PushButton.setText(_translate("MainUI", " Settings ")) 139 | self.preview_PushButton.setToolTip(_translate("MainUI", "Show Original Image and Preview of the Quantized Images")) 140 | self.preview_PushButton.setText(_translate("MainUI", "Show Image >>")) 141 | import ui.resources.icons_rc 142 | -------------------------------------------------------------------------------- /rustdavinci/ui/views/mainui.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | MainUI 4 | 5 | 6 | 7 | 0 8 | 0 9 | 240 10 | 450 11 | 12 | 13 | 14 | 15 | 240 16 | 450 17 | 18 | 19 | 20 | 21 | 240 22 | 450 23 | 24 | 25 | 26 | RustDaVinci 27 | 28 | 29 | 30 | :/icons/RustDaVinci-icon.ico:/icons/RustDaVinci-icon.ico 31 | 32 | 33 | 34 | 35 | 36 | 10 37 | 10 38 | 220 39 | 45 40 | 41 | 42 | 43 | 44 | 10 45 | 75 46 | true 47 | false 48 | false 49 | true 50 | 51 | 52 | 53 | false 54 | 55 | 56 | false 57 | 58 | 59 | Qt::StrongFocus 60 | 61 | 62 | Qt::DefaultContextMenu 63 | 64 | 65 | false 66 | 67 | 68 | Load Image from File or URL 69 | 70 | 71 | -1 72 | 73 | 74 | Qt::LeftToRight 75 | 76 | 77 | false 78 | 79 | 80 | 81 | 82 | 83 | Qt::ImhNone 84 | 85 | 86 | Load Image... 87 | 88 | 89 | 90 | :/icons/load_image_icon.png:/icons/load_image_icon.png 91 | 92 | 93 | 94 | 220 95 | 45 96 | 97 | 98 | 99 | false 100 | 101 | 102 | false 103 | 104 | 105 | false 106 | 107 | 108 | true 109 | 110 | 111 | 112 | 113 | 114 | 10 115 | 60 116 | 220 117 | 45 118 | 119 | 120 | 121 | 122 | 10 123 | 75 124 | true 125 | false 126 | false 127 | 128 | 129 | 130 | Capture the painting control area manually or automatically 131 | 132 | 133 | Capture Control Area... 134 | 135 | 136 | 137 | :/icons/select_area_icon.png:/icons/select_area_icon.png 138 | 139 | 140 | 141 | 220 142 | 45 143 | 144 | 145 | 146 | true 147 | 148 | 149 | 150 | 151 | false 152 | 153 | 154 | 155 | 10 156 | 110 157 | 220 158 | 45 159 | 160 | 161 | 162 | 163 | 10 164 | 75 165 | true 166 | false 167 | 168 | 169 | 170 | Paint the Image 171 | 172 | 173 | Qt::ImhNone 174 | 175 | 176 | Paint Image 177 | 178 | 179 | 180 | :/icons/paint_image_icon.png:/icons/paint_image_icon.png 181 | 182 | 183 | 184 | 220 185 | 45 186 | 187 | 188 | 189 | true 190 | 191 | 192 | 193 | 194 | 195 | 10 196 | 160 197 | 220 198 | 45 199 | 200 | 201 | 202 | 203 | 10 204 | 75 205 | true 206 | false 207 | 208 | 209 | 210 | Show RustDaVinci Settings 211 | 212 | 213 | Settings 214 | 215 | 216 | 217 | :/icons/settings_icon.png:/icons/settings_icon.png 218 | 219 | 220 | 221 | 220 222 | 45 223 | 224 | 225 | 226 | true 227 | 228 | 229 | 230 | 231 | 232 | 17 233 | 220 234 | 201 235 | 16 236 | 237 | 238 | 239 | Qt::Horizontal 240 | 241 | 242 | 243 | 244 | false 245 | 246 | 247 | 248 | 10 249 | 350 250 | 221 251 | 41 252 | 253 | 254 | 255 | Show Original Image and Preview of the Quantized Images 256 | 257 | 258 | Show Image >> 259 | 260 | 261 | 262 | 263 | 264 | 10 265 | 400 266 | 221 267 | 21 268 | 269 | 270 | 271 | 0 272 | 273 | 274 | false 275 | 276 | 277 | Qt::Horizontal 278 | 279 | 280 | false 281 | 282 | 283 | 284 | 285 | 286 | 10 287 | 240 288 | 221 289 | 101 290 | 291 | 292 | 293 | false 294 | 295 | 296 | true 297 | 298 | 299 | Qt::NoTextInteraction 300 | 301 | 302 | 303 | 304 | 305 | 306 | 307 | 308 | 309 | 310 | -------------------------------------------------------------------------------- /screenshots/Kirito.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alexemanuelol/rustdavinci/89c749f78b4922383acc70b503e1e68a50c02f5f/screenshots/Kirito.jpg -------------------------------------------------------------------------------- /screenshots/MrRobot.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alexemanuelol/rustdavinci/89c749f78b4922383acc70b503e1e68a50c02f5f/screenshots/MrRobot.jpg -------------------------------------------------------------------------------- /screenshots/RustReference.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alexemanuelol/rustdavinci/89c749f78b4922383acc70b503e1e68a50c02f5f/screenshots/RustReference.jpg -------------------------------------------------------------------------------- /screenshots/RustTheShining.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alexemanuelol/rustdavinci/89c749f78b4922383acc70b503e1e68a50c02f5f/screenshots/RustTheShining.jpg -------------------------------------------------------------------------------- /screenshots/RustVikings.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alexemanuelol/rustdavinci/89c749f78b4922383acc70b503e1e68a50c02f5f/screenshots/RustVikings.jpg -------------------------------------------------------------------------------- /screenshots/Stormtrooper.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alexemanuelol/rustdavinci/89c749f78b4922383acc70b503e1e68a50c02f5f/screenshots/Stormtrooper.jpg -------------------------------------------------------------------------------- /screenshots/Troll.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alexemanuelol/rustdavinci/89c749f78b4922383acc70b503e1e68a50c02f5f/screenshots/Troll.jpg -------------------------------------------------------------------------------- /screenshots/darthvader.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alexemanuelol/rustdavinci/89c749f78b4922383acc70b503e1e68a50c02f5f/screenshots/darthvader.jpg -------------------------------------------------------------------------------- /setup.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | 4 | from setuptools import setup 5 | 6 | NAME = "RustDaVinci" 7 | VERSION = "0.1" 8 | DESCRIPTION = "Automatic Sign Art Painter for the game Rust by Facepunch" 9 | AUTHOR = "Alexander Emanuelsson" 10 | EMAIL = "Alexander.Emanuelsson94@gmail.com" 11 | URL = "https://github.com/alexemanuelol/RustDaVinci" 12 | REQUIRED = [ 13 | "Pillow==8.3.2", 14 | "PyAutoGUI==0.9.41", 15 | "pypiwin32==223", 16 | "colorama==0.4.1", 17 | "termcolor==1.1.0", 18 | "pynput==1.4.2", 19 | "numpy==1.16.2", 20 | "opencv-python==4.0.0.21", 21 | "pyqt5-tools==5.13.0.1.5", 22 | "PyQt5==5.13.1" 23 | ] 24 | 25 | with open("README.md") as file: 26 | readme = file.read() 27 | 28 | with open("LICENSE") as file: 29 | license = file.read() 30 | 31 | 32 | setup( 33 | name=NAME, 34 | version=VERSION, 35 | description=DESCRIPTION, 36 | long_description=readme, 37 | author=AUTHOR, 38 | author_email=EMAIL, 39 | url=URL, 40 | license=license, 41 | install_requires=REQUIRED, 42 | classifiers=[ 43 | "Programming Language :: Python", 44 | "Programming Language :: Python :: 3.7", 45 | "License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)" 46 | ] 47 | ) 48 | --------------------------------------------------------------------------------