//################################################## //agenttype_bitmaporicon_setsource //################################################## int agenttype_bitmaporicon_setsource(agent *a, char *parameterstring) { //Declare variables const char *string_dialogtitles[2] = {"Select Image", "Select Icon"}; const char *string_dialogfilts[2] = {"Image Files(*.png;*.bmp;*.jpg;*.gif;*.tif)\0*.png;*.bmp;*.jpg;*.gif;*.tif\0PNG(*.png)\0*.png\0BMP(*.bmp)\0*.bmp\0JPG(*.jpg)\0*.jpg\0GIF(*.gif)\0*.gif\0All Files(*.*)\0*.*\0\0*.*\0\0", "Icon Files(*.ico;*.exe;*.dll;*.icl;*.lnk)\0*.ico;*.exe;*.dll;*.icl;*.lnk\0All Files(*.*)\0*.*\0\0" }; const char *string_dialogext[2] = {"", ".ico"}; const UINT uint_loadtype[2] = {IMAGE_BITMAP, IMAGE_ICON}; char *pathstring; //Get the agent details agenttype_bitmap_details *details = (agenttype_bitmap_details *) a->agentdetails; int typeindex = (details->is_icon ? 1 : 0); //If the browse option is chosen if (!stricmp(parameterstring, "*browse*")) { parameterstring = dialog_file(string_dialogfilts[typeindex], string_dialogtitles[typeindex], NULL /*config_path_plugin*/, string_dialogext[typeindex], false); if (!parameterstring) { //message_override = true; return 2; } //If we have an absolute path, and only a relative path is necessary int lenpath = strlen(config_path_plugin); if (!strnicmp(config_path_plugin, parameterstring, lenpath)) { strcpy(parameterstring, ¶meterstring[lenpath]); } } //Declare variables char plugin_path[MAX_PATH]; char *temp = parameterstring; //If we have an actual string... if (temp[0] && temp[1] != ':') { // reconstruct from relative path temp = plugin_path; strcpy(temp, config_path_plugin); strcat(temp, parameterstring); } //Copy the parameter string details->filename = new_string(parameterstring); details->absolute_path = new_string(temp); //Return 0 for success return 0; }
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //plugin_message //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ int plugin_message(int tokencount, char *tokens[], bool from_core, module* caller) { char *filename; if (tokencount == 3 && !stricmp(tokens[2], szBActionSave)) { config_save(config_path_mainscript); return 0; } else if (!stricmp(tokens[2], szBActionSaveAs)) { if (tokencount == 4) { config_save(tokens[3]); } else { if ((filename = dialog_file(szFilterScript, "Save Configuration Script", ".rc", config_path_plugin, true))) { config_save(filename); } } return 0; } else if (tokencount == 3 && !stricmp(tokens[2], szBActionRevert)) { plugin_reconfigure(true); return 0; } else if (!stricmp(tokens[2], szBActionLoad)) { if (tokencount == 4) { config_load2(tokens[3], caller); return 0; } else if (tokencount == 3) { if ((filename = dialog_file(szFilterScript, "Load Configuration Script", ".rc", config_path_plugin, false))) { config_load2(filename, caller); } return 0; } else if (tokencount == 6) { if (0 == stricmp(tokens[4], "from")) { config_load(tokens[5], caller, tokens[3]); return 0; } else if (0 == stricmp(tokens[4], "into")) { config_load(tokens[3], module_get(tokens[5])); return 0; } } else if (tokencount == 8 && 0 == stricmp(tokens[4], "from") && 0 == stricmp(tokens[6], "into")) { config_load(tokens[5], module_get(tokens[7]), tokens[3]); return 0; } } else if (!stricmp(tokens[2], szBActionAbout)) { if (tokencount == 3) { MessageBox(NULL, szPluginAbout, szVersion, MB_OK|MB_SYSTEMMODAL); return 0; } else if (tokencount == 4 && !stricmp(tokens[3], "LastControl")) { MessageBox(NULL, szPluginAboutLastControl, szAppName, MB_OK|MB_SYSTEMMODAL); return 0; } else if (tokencount == 4 && !stricmp(tokens[3], "QuickHelp")) { MessageBox(NULL, szPluginAboutQuickRef, szAppName, MB_OK|MB_SYSTEMMODAL); return 0; } } else if (!stricmp(tokens[2], szBActionEdit)) { //SendMessage(plugin_hwnd_blackbox, BB_EDITFILE, (WPARAM)-1, (LPARAM) config_path_mainscript); //return 0; char temp[MAX_PATH]; GetBlackboxEditor(temp); BBExecute(NULL, "",temp , config_path_mainscript, NULL, SW_SHOWNORMAL, false); return 0; } else if (tokencount == 5 && !stricmp(tokens[2], szBActionSetPluginProperty)) { for (struct plugin_properties *p = plugin_properties; p->key; p++) if (p->data && 0 == stricmp(tokens[3], p->key)) { switch (p->type) { case M_BOL: if (config_set_bool(tokens[4], (bool*)p->data)) break; return 1; case M_INT: if (config_set_int(tokens[4], (int*)p->data)) break; return 1; case M_STR: if (config_set_str(tokens[4], (char**)p->data)) break; return 1; default: return 1; } if (p->update) control_invalidate(); if (from_core) menu_update_global(); return 0; } } else if (tokencount == 4 && !stricmp(tokens[2], szBActionOnLoad) ) { config_set_str(tokens[3],&(globalmodule.actions[MODULE_ACTION_ONLOAD])); return 0; } else if (tokencount == 4 && !stricmp(tokens[2], szBActionOnUnload) ) { config_set_str(tokens[3],&(globalmodule.actions[MODULE_ACTION_ONUNLOAD])); return 0; } return 1; }
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //controltype_label_message //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ int controltype_label_message(control *c, int tokencount, char *tokens[]) { // token strings enum { T_NONE = 0, T_STYLE , T_VALIGN , T_HALIGN , T_HASTITLE , T_LOCKPOS , T_PLUGINLOAD , T_PLUGINUNLOAD , T_PLUGINSETPOS , T_PLUGINSHOW , T_PLUGINABOUT }; extern char szWPStyle []; static struct token_check controltype_label_property_tokens[] = { { szWPStyle, T_STYLE , 1 }, { "VAlign", T_VALIGN , 1 }, { "HAlign", T_HALIGN , 1 }, { "HasTitleBar", T_HASTITLE , 1 }, { "IsLocked", T_LOCKPOS , 1 }, { NULL } }; static struct token_check controltype_label_plugin_property_tokens[] = { { "IsVisible", T_PLUGINSHOW , 1 }, { "Position", T_PLUGINSETPOS , 2 }, { NULL } }; static struct token_check controltype_label_plugin_tokens[] = { { "Load", T_PLUGINLOAD , 1 }, { "Unload", T_PLUGINUNLOAD , 1 }, { "About", T_PLUGINABOUT , 0 }, { szBActionPluginSetProperty, (UINT_PTR)controltype_label_plugin_property_tokens , 2 }, { NULL } }; static struct token_check controltype_label_message_tokens[] = { { szBActionSetControlProperty, (UINT_PTR)controltype_label_property_tokens, 2 }, { szBActionPlugin, (UINT_PTR)controltype_label_plugin_tokens, 2 }, { NULL } }; // ----------------- //Get the details controltype_label_details *details = (controltype_label_details *) c->controldetails; //If set control details int i; int curtok = 2; switch (token_check(controltype_label_message_tokens, &curtok, tokencount, tokens)) { // ----------------- case T_STYLE: if (-1 != (i = get_string_index(tokens[curtok], szStyleNames))) { c->windowptr->style = i; style_draw_invalidate(c); return 0; } break; // ----------------- case T_HALIGN: if (-1 != (i = get_string_index(tokens[curtok], label_haligns))) { details->halign = i; controltype_label_updatesettings(details); style_draw_invalidate(c); return 0; } break; // ----------------- case T_VALIGN: if (-1 != (i = get_string_index(tokens[curtok], label_valigns))) { details->valign = i; controltype_label_updatesettings(details); style_draw_invalidate(c); return 0; } break; // ----------------- case T_HASTITLE: if (details->is_frame && config_set_bool(tokens[curtok], &details->has_titlebar)) { style_draw_invalidate(c); return 0; } break; // ----------------- case T_LOCKPOS: if (details->is_frame && config_set_bool(tokens[curtok], &details->is_locked)) return 0; break; // ----------------- case T_PLUGINLOAD: if (details->is_frame) { char *plugin_name = tokens[curtok]; if (0 == strcmp(plugin_name, "*browse*")) { // "open file" dialog plugin_name = dialog_file("Plugins\0*.dll\0", "Add Plugin" , NULL, ".dll", false); if (NULL == plugin_name) { //message_override = true; return 2; } } ModuleInfo * m = loadPlugin(&details->module_info, c->windowptr->hwnd, plugin_name); if (m) { variables_set(false, "LastPlugin", m->module_name); return 0; } } break; // ----------------- case T_PLUGINUNLOAD: if (unloadPlugin(&details->module_info, tokens[curtok])) return 0; break; // ----------------- case T_PLUGINSETPOS: { int x, y; if (config_set_int(tokens[curtok], &x) && config_set_int(tokens[1+curtok], &y) && plugin_setpos(details->plugin_info, tokens[-2+curtok], x, y) ) return 0; return 0; // dont generate an error here... } break; // ----------------- case T_PLUGINSHOW: { bool show; if (plugin_getset_show_state(details->plugin_info, tokens[-2+curtok], config_set_bool(tokens[curtok], &show) ? show : 2) ) return 0; return 0; // dont generate an error here... } break; // ----------------- case T_PLUGINABOUT: { aboutPlugins(details->module_info, c->controlname); return 0; } break; // ----------------- //Must be an agent message default: return agent_controlmessage(c, tokencount, tokens, CONTROLTYPE_LABEL_AGENT_COUNT, details->agents, controltype_label_agentnames, controltype_label_agenttypes); } return 1; }