Tool Types
  • Order of the Butterfly
    Order of the Butterfly
    Posts: 186 from 2003/10/23
    i wan to port a little game on morphos, and i want to store in the tooltypes of the icon the with and the height of the screen/window of the game.

    how can i read/write this parameters on the icon of the game?

    there is some example/source of an utility to read about?
    I'm nerdy in the extreme
    And whiter than sour cream

    White&Nerdy 2006 Al Yankovic
  • »14.01.13 - 10:41
    Profile
  • Moderator
    Develin
    Posts: 100 from 2003/4/19
    From: Karlstad, Sweden
    I found this in my little codedump-drawer =)
    Ahm, the code looks awful without spaces, but maybe it can help you somehow...

    Code:

    #include <dos/dos.h>
    #include <workbench/workbench.h>
    #include <proto/exec.h>
    #include <proto/dos.h>
    #include <proto/icon.h>
    #include <workbench/startup.h>

    static BPTR tmpcon;

    void fetchtype(struct WBArg *wbarg)
    {
    struct DiskObject *dobj;
    char **toolarray;
    char *temp;

    if ((*wbarg->wa_Name) && (dobj=GetDiskObject(wbarg->wa_Name)))
    {
    toolarray = (char **)dobj->do_ToolTypes;

    if ((temp = FindToolType((STRPTR *)toolarray,"NAME")))
    FPrintf(tmpcon, "Found argument - Name : %sn", temp);

    if ((temp = FindToolType((STRPTR *)toolarray,"AGE")))
    FPrintf(tmpcon, "Found argument - Age : %sn", temp);

    if ((temp = FindToolType((STRPTR *)toolarray,"EMAIL")))
    FPrintf(tmpcon, "Found argument - Email: %sn", temp);

    if ((temp = FindToolType((STRPTR *)toolarray,"URL")))
    FPrintf(tmpcon, "Found argument - URL : %sn", temp);

    FreeDiskObject(dobj);
    }
    }

    int handlewbargs(int argc, char **argv)
    {
    struct WBStartup *WBenchMsg;
    struct WBArg *wbarg;
    //BPTR olddir = -1;
    LONG olddir = -1;
    LONG i;

    if (argc == 0)
    {
    tmpcon = Open("CON:0/0/640/200/WB-Argument", MODE_NEWFILE);
    WBenchMsg = (struct WBStartup *)argv;

    for (i=0, wbarg=WBenchMsg->sm_ArgList ; i < WBenchMsg->sm_NumArgs; i++, wbarg++)
    {
    olddir = -1;

    if ((wbarg->wa_Lock)&&(*wbarg->wa_Name))
    olddir = CurrentDir(wbarg->wa_Lock);

    fetchtype(wbarg);

    if(olddir != -1)
    CurrentDir(olddir);
    }
    }
    }

    int main(int argc, char **argv)
    {
    if (argc == 0)
    {
    handlewbargs(argc, argv);

    if (tmpcon)
    {
    FPrintf(tmpcon, "Program started from Workbench!n");
    Delay(200);
    Close(tmpcon);
    }
    }
    else
    Printf("Program started from Shell!n");

    return(RETURN_OK);
    }



    [ Edited by Develin 14.01.2013 - 13:44 ]
  • »14.01.13 - 11:42
    Profile Visit Website
  • Order of the Butterfly
    Order of the Butterfly
    Posts: 186 from 2003/10/23
    thanks i will try it :)
    I'm nerdy in the extreme
    And whiter than sour cream

    White&Nerdy 2006 Al Yankovic
  • »14.01.13 - 14:13
    Profile