void
dmz::QtPluginCanvasObjectBasic::_init (Config &local) {

   _canvasModuleName = config_to_string ("module.canvas.name", local);

   _defaultAttributeHandle = activate_default_object_attribute (
      ObjectCreateMask | ObjectDestroyMask);

   const String StateAttrName (
      config_to_string ("attribute.state.name", local, ObjectAttributeDefaultName));

   _stateAttributeHandle = activate_object_attribute (StateAttrName, ObjectStateMask);
   _zValue = config_to_int32 ("defaults.zValue", local, _zValue);

   _itemIgnoresTransformations = config_to_boolean (
      "defaults.itemIgnoresTransformations",
      local,
      _itemIgnoresTransformations);

   Config templ;
   if (local.lookup_all_config ("template", templ)) {

      ConfigIterator it;
      Config objTemplate;
      while (templ.get_next_config (it, objTemplate)) {

         String templateName = config_to_string ("name", objTemplate, "");
         Config *config = new Config (objTemplate);
         if (templateName != "" && config && *config &&
            _templateConfigTable.store (templateName, config)) {}
         else { delete config; config = 0; }
      }
   }
}
void
dmz::RenderModuleCoreOSGBasic::_init (Config &local, Config &global) {

   const String UpStr = config_to_string ("osg-up.value", local, "y").to_lower ();
   if (UpStr == "y") { set_osg_y_up (); _log.info << "OSG render Y is up." << endl; }
   else if (UpStr == "z") { set_osg_z_up (); _log.info << "OSG render Z is up" << endl; }
   else {

      _log.warn << "Unknown osg up type: " << UpStr << ". Defaulting to Y up." << endl;
   }

   Config pluginList;

   if (local.lookup_all_config ("plugin-list.plugin", pluginList)) {

      RuntimeContext *context (get_plugin_runtime_context ());

      if (dmz::load_plugins (context, pluginList, local, global, _extensions, &_log)) {

         _extensions.discover_plugins ();
         _extensions.discover_external_plugin (this);
      }
   }

   osgDB::Registry *reg = osgDB::Registry::instance ();
   Config pathList;

   if (reg && local.lookup_all_config ("loader.path", pathList)) {

      osgDB::FilePathList &fpl = reg->getLibraryFilePathList ();

      ConfigIterator it;
      Config path;

      while (pathList.get_next_config (it, path)) {

         String pathStr = config_to_string ("value", path);

         if (get_absolute_path (pathStr, pathStr)) {

            fpl.push_back (pathStr.get_buffer ());
         }
      }

   }

   if(reg) {

      reg->setBuildKdTreesHint(osgDB::ReaderWriter::Options::BUILD_KDTREES);
   }

   _defaultHandle = activate_default_object_attribute (
      ObjectDestroyMask | ObjectPositionMask | ObjectScaleMask | ObjectOrientationMask);

   _bvrHandle = config_to_named_handle (
      "bounding-volume-radius-attribute.name",
      local,
      ObjectAttributeBoundingVolumeRaidusName,
      get_plugin_runtime_context ());
}
Exemplo n.º 3
0
/*!

\brief Find resource.
\param[in] ResourceName String containing the name of the resource file.
\return Returns a String containing the found resource file. Will return an empty
string if the resource is not found.

*/
dmz::String
dmz::Resources::find_file (const String &ResourceName) const {

   String result;

   if (_context) {

      Config *rc = _context->rcTable.lookup (ResourceName);

      if (rc) {

         StringContainer searchPath;
         const String FileName = config_to_string ("file", *rc);
         const String PathName = config_to_string ("path", *rc);
         StringContainer *path = _context->pathTable.lookup (PathName);
         if (path) { searchPath = *path; }

         if (!dmz::find_file (searchPath, FileName, result) && _log) {

            _log->error << "Unable to find file: " << FileName << " for resource: "
               << ResourceName << endl;
         }
      }
      else if (_log) {

         _log->error << "Unable to find resource: " << ResourceName << endl;
      }
   }

   return result;
}
void
dmz::QtPluginCanvasObjectBasic::_process_item_text (
      ObjectStruct &os,
      const Config &TextList) {

   ConfigIterator it;
   Config cd;

   while (TextList.get_next_config (it, cd)) {

      const String Name (config_to_string ("name", cd));
      const String AttrName (config_to_string ("attribute", cd));
      const Handle AttrHandle (activate_object_attribute (AttrName, ObjectTextMask));

      QGraphicsItem *item (os.itemTable.lookup (Name));

      if (AttrHandle && item) {

         QtCanvasObjectTextTable *textTable (os.textTable.lookup (AttrHandle));

         if (!textTable) {

            textTable = new QtCanvasObjectTextTable ();
            os.textTable.store (AttrHandle, textTable);
         }

         QtCanvasObjectText *text (qgraphicsitem_cast<QtCanvasObjectText *>(item));

         if (textTable && text) {

            textTable->store (Name, text);
         }
      }
   }
}
Exemplo n.º 5
0
	void handle_stuff_list_selection()
	{
		int selected = model_.stuff_list->get_selected_row();
		if(selected == -1) {
			model_.set_inspect_window_text("");
			return;
		}

		int i = 0; ///@todo replace with precached data
		const config& vars = resources::gamedata
									 ? resources::gamedata->get_variables()
									 : config();

		FOREACH(const AUTO & a, vars.attribute_range())
		{
			if(selected == i) {
				model_.set_inspect_window_text(a.second);
				return;
			}
			i++;
		}

		FOREACH(const AUTO & c, vars.all_children_range())
		{
			for (unsigned int j = 0; j < model_.get_num_page(config_to_string(c.cfg)); ++j) {
				if (selected == i) {
					model_.set_inspect_window_text(config_to_string(c.cfg), j);
					return;
				}
				i++;
			}
		}
	}
void
dmz::QtPluginCanvasObjectBasic::_process_item_switch (
      ObjectStruct &os,
      const Config &SwitchList) {

   ConfigIterator it;
   Config cd;

   while (SwitchList.get_next_config (it, cd)) {

      const String DataName (cd.get_name ().to_lower ());

      if (DataName == "state") {

         const String StateName (config_to_string ("name", cd));

         Mask state;
         _defs.lookup_state (StateName, state);

         const String StateGroup (config_to_string ("group", cd));

         _process_item_state (os, state, StateGroup, cd);
      }
      else if (DataName == "flag") {

         const String AttrName (config_to_string ("attribute", cd));
         const Handle AttrHandle (activate_object_attribute (AttrName, ObjectFlagMask));
//         _process_item_flag (os, cd);
      }
   }
}
Exemplo n.º 7
0
void
dmz::QtPluginCanvasObject::_init (Config &local, Config &global) {

   _canvasModuleName = config_to_string ("module.canvas.name", local);

   Config pluginList;

   if (local.lookup_all_config ("plugins.plugin", pluginList)) {

      RuntimeContext *context (get_plugin_runtime_context ());

      if (dmz::load_plugins (context, pluginList, local, global, _extensions, &_log)) {

         _extensions.discover_plugins ();
      }
   }

   _defaultAttributeHandle = activate_default_object_attribute (
      ObjectCreateMask |
      ObjectDestroyMask |
      ObjectPositionMask |
      ObjectOrientationMask);

   _linkAttributeHandle = activate_object_attribute (
      ObjectAttributeLayerLinkName,
      ObjectLinkMask | ObjectUnlinkMask);

#if 0
   Config preLoadList;

   if (local.lookup_all_config ("preload", preLoadList)) {

      Config data;
      ConfigIterator it;

      Boolean done (!preLoadList.get_first_config (it, data));

      while (!done) {

         ObjectType objType;
         Mask objState;

         if (_defs.lookup_object_type (config_to_string ("type", data), objType)) {

            _defs.lookup_state (config_to_string ("state", data), objState);

            _log.info << "Pre-Loading object of type: " << objType.get_name () << endl;
            _get_model_struct (objType, objState);
         }

         done = !preLoadList.get_next_config (it, data);
      }
   }
#endif
}
Exemplo n.º 8
0
void
dmz::QtPluginPreferences::_init (Config &local) {
   
   RuntimeContext *context (get_plugin_runtime_context ());
      
   setObjectName (get_plugin_name ().get_buffer ());
   
   qframe_config_read ("frame", local, this);
   
   _mainWindowModuleName = config_to_string (
      "module.mainWindow.name",
      local,
      "dmzQtModuleMainWindowBasic");
      
   _preferencesAction = new QAction (this),

   _preferencesAction->setMenuRole (QAction::PreferencesRole);

   _preferencesAction->setText (
      config_to_string ("preferences-menu.text", local, "&Preferences...").get_buffer ());

   connect (
      _preferencesAction, SIGNAL (triggered ()),
      this, SLOT (show ()));

   _menuName = config_to_string ("edit-menu.text", local, _menuName);
   
   _ui.tabWidget->removeTab (0);
   
   Config widgetList;

   if (local.lookup_all_config ("widget", widgetList)) {

      ConfigIterator it;
      Config widget;

      while (widgetList.get_next_config (it, widget)) {

         const String WidgetName (config_to_string ("name", widget));
         
         if (WidgetName && !_widgetTable.lookup (WidgetName)) {

            WidgetStruct *ws (new WidgetStruct);
            
            if (ws) {
               
               ws->title = config_to_string ("title", widget);
            }

            if (!_widgetTable.store (WidgetName, ws)) { delete ws; ws = 0; }
         }
      }
   }
}
Exemplo n.º 9
0
dmz::NetExtPacketCodecObjectNative::ObjectAttributeAdapter *
dmz::NetExtPacketCodecObjectNative::create_object_adapter (
      Config &local,
      RuntimeContext *context,
      Log &log) {

   Adapter *result (0);

   const String Type = config_to_string ("type", local).to_lower ();

   if (Type == "link") { result = new SubLink (local, context); }
   else if (Type == "superlink") { result = new SuperLink (local, context); }
   else if (Type == "counter") { result = new Counter (local, context); }
   else if (Type == "state") { result = new State (local, context); }
   else if (Type == "flag") { result = new Flag (local, context); }
   else if (Type == "position") { result = new Position (local, context); }
   else if (Type == "orientation") { result = new Orientation (local, context); }
   else if (Type == "velocity") { result = new Velocity (local, context); }
   else if (Type == "acceleration") { result = new Acceleration (local, context); }
   else if (Type == "scale") { result = new Scale (local, context); }
   else if (Type == "vector") { result = new VectorAttr (local, context); }
   else if (Type == "scalar") { result = new Scalar (local, context); }
   else if (Type == "scalar-array") { result = new ScalarArray (local, context); }
   else if (Type == "time-stamp") { result = new TimeStamp (local, context); }
   else if (Type == "write-stamp") { result = new WriteStamp (local, context); }
   else if (Type == "text") { result = new Text (local, context); }
   else {

      log.error << "Unknown object attribute adapter type: " << Type << endl;
   }

   return result;
}
Exemplo n.º 10
0
// ObjectPluginHighlight Interface
void
dmz::ObjectPluginHighlight::_init (Config &local) {

   _highlightAttr = activate_object_attribute (
      ObjectAttributeHighlightName,
      ObjectFlagMask);

   _convert.set_handle (
      config_to_string ("data-convert-handle.name", local, "handle"),
      get_plugin_runtime_context ());

   _mouseMoveMsg = config_create_message (
      "mouse-move-message.name",
      local,
      "Mouse_Move_Message",
      get_plugin_runtime_context ());

   _deactivateMsg = config_create_message (
      "deactivate-message.name",
      local,
      "Object_Highlight_Deactivate_Message",
      get_plugin_runtime_context ());

   subscribe_to_message (_mouseMoveMsg);
   subscribe_to_message (_deactivateMsg);
}
Exemplo n.º 11
0
void
dmz::RenderModulePortalOSG::_init (const Config &Local) {

   _portalName = config_to_string ("portal.name", Local, _portalName);

   Config cullRangeData;
   if (Local.lookup_all_config ("visibility", cullRangeData)) {

      ConfigIterator it;
      Config cd;

      Boolean found (cullRangeData.get_first_config (it, cd));
      if (found)  {
         _fov = config_to_float32 ("fov", cd);
         _nearClip = config_to_float32 ("near", cd);
         _farClip = config_to_float32 ("far", cd);
      }
   }
   else {

      _fov = 60.0;
      _nearClip = 1.0f;
      _farClip = 10000.0f;
   }

   _log.info << "FOV: " << _fov << endl;
   _log.info << "Clip Planes: " << _nearClip << " / " << _farClip << endl;
}
Exemplo n.º 12
0
dmz::Boolean
dmz::set_qwidget_stylesheet (const String &Name, const Config &Source, QWidget *widget) {

   Boolean result (False);

   if (widget) {

      Config cd;

      if (Name) { Source.lookup_config (Name, cd); }
      else { cd = Source; }

      String qss (config_to_string ("file", cd));

      if (qss) {

         QFile file (qss.get_buffer ());
         if (file.open (QFile::ReadOnly)) {

            QString styleSheet (QLatin1String (file.readAll ()));
            widget->setStyleSheet (styleSheet);

            qDebug () << widget->objectName () << "Style Sheet:" << qss.get_buffer ();
            result = True;
         }
      }
   }

   return result;
}
Exemplo n.º 13
0
int save_config(struct config *config) {
	FILE *fd;
	fd = fopen(config->config_path_new, "w");
	if(NULL == fd) {
		log_error("Can't write to config file \"%s\".", config->config_path_new);
		return(-1);
	}
	char *buf = (char*)malloc(MAX_CONFIG_SIZE);
	int r = config_to_string(config, buf, MAX_CONFIG_SIZE);
	if(r < 0)
		goto error;
	buf[MAX_CONFIG_SIZE-1] = '\0';
	fputs(buf, fd);
	
	free(buf);
	fclose(fd);
	if(0 != rename(config->config_path_new, config->config_path)) {
		log_perror("rename(%s, %s)", config->config_path_new, config->config_path);
	}
	return(0);
	
error:;
	free(buf);
	fclose(fd);
	log_error("Can't write to config file \"%s\".", config->config_path_new);
	return(-1);
}
Exemplo n.º 14
0
void team_mode_controller::show_list(tree_view_node& node, int side)
{
	config&& cfg = dc().get_team(side).to_config();
	cfg.clear_children("ai");
	model().set_data(config_to_string(cfg));

	if(node.count_children() > 0) {
		return;
	}

	c.set_node_callback(
		view().stuff_list_entry(&node, "basic")
			.widget("name", "ai")
			.add(),
		&team_mode_controller::show_ai,
		side);
	c.set_node_callback(
		view().stuff_list_entry(&node, "basic")
			.widget("name", "recall list")
			.add(),
		&team_mode_controller::show_recall,
		side);
	c.set_node_callback(
		view().stuff_list_entry(&node, "basic")
			.widget("name", "units")
			.add(),
		&team_mode_controller::show_units,
		side);
}
QGraphicsItem *
dmz::QtPluginCanvasObjectBasic::_create_image_item (
      ObjectStruct &os,
      QGraphicsItem *parent,
      const Config &Data,
      HashTableStringTemplate<String> &table) {

   QGraphicsItem *item (0);

   String fileName = config_to_string ("resource", Data);
   String *repName = table.lookup (fileName);

   const String File = _rc.find_file (repName ? *repName : fileName).to_lower ();
   QFileInfo fi (File.get_buffer ());

   if (fi.suffix () == QLatin1String ("svg")) {

      item = _create_svg_item (os, parent, Data, table);
   }
   else {

      item = _create_pixmap_item (os, parent, Data, table);
   }

   return item;
}
Exemplo n.º 16
0
void
dmz::BorderWebInterface::_init (Config &local) {

   RuntimeContext *context = get_plugin_runtime_context ();

   _uiV8Name = config_to_string ("module.js.name", local, "dmzJsModuleUiV8QtBasic");
   _jsWindowObjectName = config_to_string ("module.js.windowObject.name", local, "dmz");
   _mainWindowName = config_to_string ("module.main-window.name", local, "dmzQtModuleMainWindowBasic");
   _frameName = config_to_string ("webframe.name", local, "DystopiaWebFrame");

   _pinIDHandle = config_to_string ("pin-handles.id.name", local);
   _pinPositionHandle = config_to_string ("pin-handles.position.name", local);
   _pinTitleHandle = config_to_string ("pin-handles.title.name", local);
   _pinDescHandle = config_to_string ("pin-handles.description.name", local);

   _addPinMessage = config_create_message (
      "message-names.add",
      local,
      "AddPinMessage",
      context,
      &_log);

   _pinAddedMessage = config_create_message (
      "message-names.add-confirm",
      local,
      "PinAddedMessage",
      context,
      &_log);

   _removePinMessage = config_create_message (
      "message-names.remove",
      local,
      "RemovePinMessage",
      context,
      &_log);

   _pinRemovedMessage = config_create_message (
      "message-names.remove-confirm",
      local,
      "PinRemovedMessage",
      context,
      &_log);

   _pinMovedMessage = config_create_message (
      "message-names.moved",
      local,
      "PinMovedMessage",
      context,
      &_log);

   _setFrameMessage = config_create_message (
      "message-names.set-interface",
      local,
      "SetInterfaceWebFrameMessage",
      context,
      &_log);
}
Exemplo n.º 17
0
void
dmz::RenderPluginHighlightOSG::_init (Config &local) {

   Config highlightList;

   if (local.lookup_all_config ("highlight", highlightList)) {

      const osg::Vec4 None (0.0f, 0.0f, 0.0f, 1.0f);

      ConfigIterator it;
      Config highlight;

      while (highlightList.get_prev_config (it, highlight)) {

         const String AttrName = config_to_string ("attribute", highlight);

         const Handle Attr = activate_object_attribute (
            AttrName,
            ObjectRemoveAttributeMask | ObjectFlagMask);

         if (Attr) {

            HighlightStruct *hs = new HighlightStruct (Attr);

            if (hs) {

               hs->color = new osg::StateSet;
               osg::ref_ptr <osg::Material> material = new osg::Material;
               material->setColorMode (osg::Material::OFF);
               osg::Vec4 color (None);
               color = config_to_osg_vec4_color ("ambient", highlight, None);
               material->setAmbient (osg::Material::FRONT_AND_BACK, color);
               color = config_to_osg_vec4_color ("diffuse", highlight, None);
               material->setDiffuse (osg::Material::FRONT_AND_BACK, color);
               color = config_to_osg_vec4_color ("specular", highlight, None);
               material->setSpecular (osg::Material::FRONT_AND_BACK, color);
               color = config_to_osg_vec4_color ("emission", highlight, None);
               material->setEmission (osg::Material::FRONT_AND_BACK, color);

               hs->color->setAttributeAndModes (
                  material.get (),
                  osg::StateAttribute::OVERRIDE | osg::StateAttribute::ON);

               hs->color->setMode (
                  GL_LIGHTING,
                  osg::StateAttribute::OVERRIDE | osg::StateAttribute::ON);

               hs->color->setTextureMode (
                  0,
                  GL_TEXTURE_2D, 
                  osg::StateAttribute::OVERRIDE | osg::StateAttribute::OFF);
            }

            hs->next = _highlightList;
            _highlightList = hs;
         }
      }
   }
}
Exemplo n.º 18
0
void team_mode_controller::show_ai_components(tree_view_node& node, int side)
{
	widget* w = node.find("name", false);
	if(label* lbl = dynamic_cast<label*>(w)) {
		std::string tag = lbl->get_label();
		tag.pop_back();
		model().set_data(config_to_string(ai::manager::to_config(side), tag));
	}
}
void
dmz::QtPluginCanvasObjectBasic::_process_item_state (
      ObjectStruct &os,
      const Mask &State,
      const String &GroupName,
      const Config &ItemList) {

   StateGroupStruct *group (os.groupTable.lookup (GroupName));

   if (!group) {

      if (!GroupName) {

         group = &(os.defaultGroup);
      }
      else {

         group = new StateGroupStruct (GroupName);

         if (os.groupTable.store (GroupName, group)) {

            group->next = os.groupList;
            os.groupList = group;
         }
         else { delete group; group = 0; }
      }
   }

   if (group) {

      StateStruct *ss (new StateStruct (State));

      ss->next = group->stateList;
      group->stateList = ss;
      group->groupState |= ss->State;

      if (!(group->defaultState) && !(ss->State)) {

         group->defaultState = ss;
      }

      ConfigIterator it;
      Config cd;

      while (ItemList.get_next_config (it, cd)) {

         const String Name (config_to_string ("name", cd));
         QGraphicsItem *item (os.itemTable.lookup (Name));

         if (item) {

            item->setVisible (False);
            ss->itemTable.store (ss->itemTable.get_count (), item);
         }
      }
   }
}
Exemplo n.º 20
0
void
dmz::RenderPluginStaticTerrainOSG::_init (Config &local) {

   Config list;

   if (local.lookup_all_config ("model", list)) {

      ConfigIterator it;
      Config model;

      while (list.get_next_config (it, model)) {

         const String ResourceName = config_to_string ("resource", model);

         if (ResourceName) {

            const String FileName = _rc.find_file (ResourceName);
            const Boolean Isect = config_to_boolean ("isect", model, True);

            if (FileName) {

               ModelStruct *ms = new ModelStruct (Isect);

               if (ms) {

                  ms->model = osgDB::readNodeFile (FileName.get_buffer ());

                  if (ms->model.valid ()) { 

                  osg::BoundingSphere bound = ms->model->computeBound ();
                  _log.info << FileName << " center: ["
                     << bound.center ().x () << ", "
                     << bound.center ().y () << ", "
                     << bound.center ().z () << "]" << endl;

                     ms->next = _modelList;
                     _modelList = ms;

                     _log.info << "Loaded model: " << FileName
                       << " (" << ResourceName << ")" << endl;
                  }
                  else {

                     delete ms; ms = 0;
                     _log.error << "Failed loading model: " << FileName
                        << " (" << ResourceName << ")" << endl;
                  }
               }
            }
         }
         else {

            _log.error << "No resource name specified for static terrain." << endl;
         }
      }
   }
}
Exemplo n.º 21
0
void unit_mode_controller::show_unit(tree_view_node& node)
{
	int i = node.describe_path().back();
	unit_map::const_iterator u = dc().units().begin();
	std::advance(u, i);
	config c_unit;
	u->write(c_unit);
	model().set_data(config_to_string(c_unit));
}
Exemplo n.º 22
0
void team_mode_controller::show_recall_unit(tree_view_node& node, int side)
{
	int i = node.describe_path().back();
	auto u = dc().get_team(side).recall_list().begin();
	std::advance(u, i);
	config c_unit;
	(*u)->write(c_unit);
	model().set_data(config_to_string(c_unit));
}
Exemplo n.º 23
0
void
dmz::CyclesPluginGridOSG::_init (Config &local) {

    _imageResource = config_to_string ("image.resource", local, "grid");

    _tileSize = config_to_float64 ("tile.size", local, _tileSize);
    _minGrid = config_to_float64 ("tile.min", local, _minGrid);
    _maxGrid = config_to_float64 ("tile.max", local, _maxGrid);
}
Exemplo n.º 24
0
static void dump_type(const struct arsc_type *type)
{
	char c[CONFIG_LEN];

	config_to_string(&type->data.config, c);
	printf("type: id=0x%02x entry_count=%d entries_start=0x%02x config=%s\n",
	       dtohs(type->data.id), dtohl(type->data.entry_count),
	       dtohl(type->data.entries_start), c);
}
Exemplo n.º 25
0
void
dmz::EntityPluginOverlayDead::_init (Config &local) {

   Definitions defs (get_plugin_runtime_context (), &_log);

   defs.lookup_state (DefaultStateNameDead, _deadState);

   activate_default_object_attribute (ObjectStateMask);

   _hilAttrHandle = activate_object_attribute (
      ObjectAttributeHumanInTheLoopName,
      ObjectFlagMask);

   _overlaySwitchName =
      config_to_string ("overlay.switch.name", local, _overlaySwitchName);

   _overlayScaleName = config_to_string ("overlay.scale.name", local, _overlayScaleName);
}
Exemplo n.º 26
0
// QtPluginIconPalletTool Interface
void
dmz::QtPluginIconPalletTool::_add_type (const ObjectType &Type) {

   const String IconResource = config_to_string (
      get_plugin_name () + ".resource",
      Type.get_config());

   const String IconName = _rc.find_file (IconResource);

   if (IconName) {

      const String Name = Type.get_name ();

      if (Name) {

         QImage back (
            (int)_iconExtent,
            (int)_iconExtent,
            QImage::Format_ARGB32_Premultiplied);
         QPainter painter (&back);
         painter.setCompositionMode (QPainter::CompositionMode_Source);
         painter.fillRect (back.rect (), Qt::transparent);
         painter.setCompositionMode (QPainter::CompositionMode_SourceOver);
         QSvgRenderer qsr (QString (IconName.get_buffer ()));
         QRectF size = qsr.viewBoxF ();
         qreal width = size.width ();
         qreal height = size.height ();
         qreal scale = (width > height) ? width : height;
         if (scale <= 0.0f) { scale = 1.0f; }
         scale = _iconExtent / scale;
         width *= scale;
         height *= scale;
         size.setWidth (width);
         size.setHeight (height);
         if (height < _iconExtent) { size.moveTop ((_iconExtent - height) * 0.5f); }
         if (width < _iconExtent) { size.moveLeft ((_iconExtent - width) * 0.5f); }
         qsr.render (&painter, size);
         painter.end ();
         QIcon icon;
         icon.addPixmap (QPixmap::fromImage (back));
         QStandardItem *item = new QStandardItem (icon, Name.get_buffer ());
         item->setEditable (false);
         _model.appendRow (item);
      }
   }
   else if (IconResource) {

      _log.error << "Unable to find icon resource: " << IconResource
          << " for object type: " << Type.get_name () << endl;
   }

   RuntimeIterator it;
   ObjectType next;

   while (Type.get_next_child (it, next)) { _add_type (next); }
}
void
dmz::RenderPluginObjectLoaderOSG::_init (Config &local) {

   activate_default_object_attribute (ObjectDestroyMask);

   _modelAttrHandle = activate_object_attribute (
      config_to_string ("attribute.model.name", local, "Object_Model_Attribute"),
      ObjectTextMask |
      ObjectRemoveAttributeMask);
}
Exemplo n.º 28
0
void
dmz::RenderExtViewerOSG::_init (const Config &Local) {

   osg::DisplaySettings *ds = osg::DisplaySettings::instance ();
   if (ds) { ds->setNumMultiSamples (config_to_int32 ("aa.samples", Local, 0)); }

   _viewerName = config_to_string ("portal.name", Local, _viewerName);

   _title = config_to_string ("window-title.value", Local, _title);

   const Boolean Fullscreen = config_to_boolean ("window.fullscreen", Local, False);
   const Boolean Centered = config_to_boolean ("window.center", Local, True);
   Int32 windowLeft = config_to_uint32 ("window.left", Local, 100);
   Int32 windowTop = config_to_uint32 ("window.top", Local, 100);
   const UInt32 WindowWidth = config_to_uint32 ("window.width", Local, 800);
   const UInt32 WindowHeight = config_to_uint32 ("window.height", Local, 600);
   const UInt32 Screen = config_to_uint32 ("window.screen", Local, 0);

   if (Fullscreen) { __init_viewer_fullscreen (Screen); }
   else {
         
      if (Centered) {

         __init_centered (Screen, WindowWidth, WindowHeight, windowLeft, windowTop);
      }

      __init_viewer_window (windowLeft, windowTop, WindowWidth, WindowHeight, Screen);
   }

   _log.info << "Viewer Info: ";

   if (Fullscreen) { _log.info << "Full Screen: "; }
   else {

      _log.info << WindowWidth << "x" << WindowHeight;

      if (Centered) { _log.info << " [Centered]"; }

      _log.info << " Corner: " << windowLeft << ", " << windowTop << " Screen: ";
   }

   _log.info << Screen << endl;
}
Exemplo n.º 29
0
void
dmz::AudioModulePortalBasic::_init (const Config &Local) {

   Config data;
   if (Local.lookup_config ("name", data)) {

      _name = config_to_string ("value", data);
   }

}
Exemplo n.º 30
0
void
dmz::QtPluginAppUpdater::_init (Config &local) {

    setObjectName (get_plugin_name ().get_buffer ());
    RuntimeContext *context (get_plugin_runtime_context ());

    _mainWindowModuleName = config_to_string ("module.mainWindow.name", local);
    _forceUpdate = config_to_boolean ("force-update.value", local, _forceUpdate);
    _downloadToTemp = config_to_boolean ("download-to-temp.value", local, _downloadToTemp);
    _releaseChannel = config_to_string ("release.channel", local, _releaseChannel);

    // _updateUrl = "latest/{system_name}-{release_channel}/{app_name}.xml";
    // _downloadUrl = "downloads/{app_name}-{major}-{minor}-{bug}-{build_number}";

    String host = config_to_string ("update.host", local);
    String path = config_to_string ("update.path", local);

    if (host && path) {

        _updateUrl = host + path;

        host = config_to_string ("download.host", local, host);
        path = config_to_string ("download.path", local);

        if (host && path) {
            _downloadUrl = host + path;
        }
    }

    if (_updateUrl) {
        _log.debug << "Update URL: " << _updateUrl << endl;
    }
    else {
        _log.debug << "Update URL not specified." << endl;
    }

    if (_downloadUrl) {
        _log.debug << "Download URL: " << _downloadUrl << endl;
    }
    else {
        _log.debug << "Download URL not specified." << endl;
    }

    _valueAttrHandle = config_to_named_handle (
                           "attribute.value.name",
                           local,
                           "value",
                           context);

    _updateMessageName = config_to_string ("update.message", local, _updateMessageName);
    _channelMessageName = config_to_string ("channel.message", local, _channelMessageName);
}