This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
Dave-ee Jones's profile picture

djOS -> A Bug That I Cannot See

Started by Dave-ee Jones, 23 February 2017 - 09:43 PM
Dave-ee Jones #1
Posted 23 February 2017 - 10:43 PM
I have some weird bug regarding my Control Panel in an OS I am working on.


In my Control Panel there is an Appearance menu where you can change the colour of most objects' Background colour and Text colour. However, there is something very weird happening and I have looked in all the 'Classic Mistakes' places and there is nothing wrong that I can see.

This usually means I need a fresh pair of eyes to take a look at my code for me.
That's where you guys come in.
Have a look.

"What's the bug?" you ask?

Well. When I change the colour of any one of the 'Text' objects in the Appearance menu, it will first change the Main 'Background' colour and then the Main 'Text' colour. Then if I try again it will do the next 'Text' object down (Menu 'Text' colour), and then the next and so on. When it finally reaches the bottom, it will go back to the top except it will change the 'Background' objects and will go down those next. I am very confused at what is going on here.

Knock yourself out. Feel free to play around with the code to see what you can do to make it work.

It will automatically create a config file like so:

/dj.cfg

So far it just saves object colours.


You may need to create a directory like so:


/desktop

Don't bother trying to add files/folders in there as it gets complicated. You can probably see that when you look through my code.

NOTE: The code is semi-OOP programmed so it can be easier to read and it can also be harder to read…Good luck!

THE PASTEBIN CODE: QKh35fqK


Thanks in advance and GOOD LUCK FIXING IT :D/>
Edited on 24 February 2017 - 12:59 AM
Dave-ee Jones #2
Posted 23 February 2017 - 10:55 PM
Just as a side note…


Didn't realise the Settings API was built into CC now. That's really cool! I should implement that into djOS instead of using a custom config file…Should be easier.
Dave-ee Jones #3
Posted 24 February 2017 - 02:00 AM
Okay just letting you know I have updated the code so that it uses the Settings API. This means you won't actually have to create your own config like you would have had to do before. Just makes it easier for those who are a bit lazy :P/>

Lookin' at you Dog and Lyqyd! :P/>
Edited on 24 February 2017 - 01:00 AM
Dog #4
Posted 24 February 2017 - 10:11 PM
Haha, how did you know I'm lazy?!? FWIW, I looked over your code and nothing jumped out at me. Then again, OOP and I don't really understand each other. I imagine most people won't bother to review 900+ lines of code without knowing where in the code they should be looking - it would help quite a bit if you posted the line numbers for the input routine and any processing and/or drawing routine(s) that might be in question. I'd be happy to give the code another look with that information; although I have the feeling someone more experienced with OOP will have a much better chance at finding something.
Dave-ee Jones #5
Posted 24 February 2017 - 10:58 PM
I am everywhere…:P/>

Okay so when you are in the Appearance menu and you click on a colour object it all happens at line 924. This refers to the function checkMouseOnColourBoxes() at line 395. If the error is somewhere it is possible it's there, but when you are inputting the colour on the Input Box it happens at line 934.

Does that help a bit?
Dog #6
Posted 24 February 2017 - 11:05 PM
Yeah, that'll give me an idea of where to focus my attention. I'll look over the code again and see if anything stands out to me.

EDIT: OK, I looked over the code again and didn't see anything that was obvious to me - sorry I'm not able to be more help. I'll take another look later and if I find anything I'll post again.
Edited on 24 February 2017 - 10:29 PM