[Ohrrpgce] SVN: james/9958 load_plank_from_file() helper function

Ralph Versteegen teeemcee at gmail.com
Sat Jan 13 07:49:06 PST 2018


On 13 January 2018 at 05:24, James Paige <Bob at hamsterrepublic.com> wrote:

> s/SliceLoadFromFile/load_plank_from_file/ in my previous mail
>
> Opps! ;)
>

Wait a minute, I just finally noticed you switched to my spelling, and have
been doing it for a long time!


>
> On Fri, Jan 12, 2018 at 8:19 AM, James Paige <Bob at hamsterrepublic.com>
> wrote:
>
>> Opps! I'll fix where I forgot to free the collection in SliceLoadFromFile
>> It looks like I am leaking the whole collection every time, even if the
>> load succeeds.
>>
>
Oh, I didn't even notice that bug! That wasn't what I meant.  The only way
to check whether SliceLoadFromFile failed or not is to check if any slices
were actually loaded... but if they didn't load, then the lookupslice will
fail anyway, so that "if col = 0 then ..." does nothing


>
>> I'm looking forward to learning more about template slices and menu
>> slices. I'll probably have to read your writeup before I understand :)
>>
>
Hmm, this is a long and unfinished writeup, and at the top I have notes to
myself to firsr finish and email, or in merge in two other writeups!

Template slices is basically just hidden slices, ignored for almost all
purposes (importantly, collision detection, so you can't click on them) but
which are shown by default in the slice editor, tagged with [TEMPLATE].
Their main use is to replace plank collections. If you want to add a new
menu item to a plankmenu, just clone a template slice (indexed with a
lookup code), instead of loading a collection and copying over the plank.
Conceivably you could have multiple item templates. So, this will let you
see the whole menu while you edit the menu slice collection.
My branch: https://bitbucket.org/rbv/ohrrpgce/commits/
d1963ff335e7afd8e82d12dd1d92df3251b2f6e8?at=templates
(This turned out a bit messy, I wanted to try to clean it up)

As for the rest of it, let me just state this core crazy idea:
Replace menu handles and menu item handles with menu slice handles and menu
item slice handles.

The "create menu" command would create *both* a new menu and a new menu
slice, which appear to be exactly the same thing from the point of view of
scripts. The handle it returns could be passed to any existing menu
command, or used as a slice handle. Note that "create menu" fits the
pattern for "create rect", "create text", etc.
Having both menus and menu slices and making them different things with
different kinds of handles, and adding commands to convert from one to the
other, seems totally unnecessary and harmfully confusing. Three different
handle types for heroes is endless trouble.
Ditto for menu items: they also would become slices, but they would be
different from other slice types in that they are always linked to a
certain menu slice, must be a descendant of that slice, and can't be
created independently. Typically they will have a single text slice child,
and various existing menu and menu item command will have the effect of
modifying that child.
We could either merge MenuDef and plankmenu entirely at a low level, or at
a higher one (so MenuDef builds on top of plankmenu or vice versa, or an
abstraction layer over the two).


>
>> ---
>> James
>>
>>
>>
>>
>> On Fri, Jan 12, 2018 at 8:04 AM, Ralph Versteegen <teeemcee at gmail.com>
>> wrote:
>>
>>>
>>>
>>> On 12 January 2018 at 13:00, <subversion at hamsterrepublic.com> wrote:
>>>
>>>> james
>>>> 2018-01-11 16:00:45 -0800 (Thu, 11 Jan 2018)
>>>> 38
>>>> load_plank_from_file() helper function
>>>> ---
>>>> U   wip/plankmenu.bas
>>>> U   wip/plankmenu.bi
>>>>
>>>
>>> + DIM col as Slice Ptr
>>> + col = NewSliceOfType(slSpecial)
>>> + SliceLoadFromFile col, filename
>>> + IF col = 0 THEN visible_debug "load_plank_from_file: unable to load
>>> slices from """ & filename & """": RETURN 0
>>>
>>> This doesn't work:  if SliceLoadFromFile fails, it doesn't delete col.
>>>
>>> I actually have a git branch where I was working on making
>>> SliceLoadFromFile return a new slice instead of modify an existing one.
>>> Which was a surprisingly large change. I don't remember why I didn't check
>>> that in; maybe it didn't seem worth the effort to finish it.
>>>
>>> BTW, I have been working on changing the way that plankmenus work. I am
>>> getting rid of "plank" collections and instead using template slices
>>> parented directly to the menu slice collection. Oh... I didn't check in
>>> template slices yet either? Well, it's basically just another Slice bit
>>> which works very similarly to Slice.Visible. Well, after planks are gone
>>> maybe plank menus should be renamed... I have a suggestion: Menu Slices. As
>>> in, promote them to a new slice type so that they can be used by scripts
>>> too, not just from FB. I have a long writeup about this which I haven't
>>> finished yet...
>>>
>>> _______________________________________________
>>> Ohrrpgce mailing list
>>> ohrrpgce at lists.motherhamster.org
>>> http://lists.motherhamster.org/listinfo.cgi/ohrrpgce-motherhamster.org
>>>
>>>
>>
>
> _______________________________________________
> Ohrrpgce mailing list
> ohrrpgce at lists.motherhamster.org
> http://lists.motherhamster.org/listinfo.cgi/ohrrpgce-motherhamster.org
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.motherhamster.org/pipermail/ohrrpgce-motherhamster.org/attachments/20180114/40d2c686/attachment.html>


More information about the Ohrrpgce mailing list