Beispiel #1
0
/*********************************************************************\
	Function name    : CCompareTableDialog::SaveResult
	Description      :
	Created at       : 10.10.01, @ 22:16:07
	Created by       : Thomas Kunert
	Modified by      :
\*********************************************************************/
void CCompareTableDialog::SaveResult()
{
	Filename fn;
	if (!fn.FileSelect(FILESELECTTYPE_ANYTHING, FILESELECT_SAVE, String())) return;

	Int32 lMaxLen = 0;

	Int32 a, lNumItems;
	lNumItems = m_wndOutputList.GetItemCount();

	for (a = 0; a < lNumItems; a++)
	{
		BaseContainer data;
		m_wndOutputList.GetItem(a, &data);
		lMaxLen = LMax(lMaxLen, data.GetString(COMPARE_LIST_NAME).GetLength());
	}
	lMaxLen += 2;

	AutoAlloc <BaseFile> pFile;
	if (!pFile)
		return;

	pFile->Open(fn, FILEOPEN_WRITE);
	for (a = 0; a < lNumItems; a++)
	{
		BaseContainer data;
		m_wndOutputList.GetItem(a, &data);
		String str = data.GetString(COMPARE_LIST_NAME);
		WriteString(pFile, str);
		Int32 b = lMaxLen - str.GetLength();
		while (b--) WriteString(pFile, " ");
		WriteString(pFile, data.GetString(COMPARE_LIST_DATA));
		LineBreak(pFile, "");
	}
}
Bool DiffDistriDialog::Command(Int32 id, const BaseContainer &msg)
{
	switch (id)
	{
	case IDC_DIFF_DISTRI_NEW_BTN:
		{
			Filename fn;
			if (fn.FileSelect(FILESELECTTYPE_ANYTHING, FILESELECT_LOAD, GeLoadString(IDS_DIFF_DISTRI_CHOOSE)))
			{
				if (!fn.CheckSuffix("zip"))
				{
					GeOutString(GeLoadString(IDS_DIFF_DISTRI_INVALID_SUFFIX), GEMB_OK | GEMB_ICONSTOP);
				}
				else
				{
					g_pResEditPrefs->arOldFiles.AddFilename(fn);
					m_pTreeView->Refresh();
				}
			}
		}
		break;

	case IDC_DIFF_DISTRI_REMOVE_BTN:
		if (m_fnSelection.Content())
		{
			g_pResEditPrefs->arOldFiles.RemoveFilename(m_fnSelection);
			m_fnSelection = Filename();
			m_pTreeView->Refresh();
		}
		break;

	case IDC_DIFF_DISTRI_NEWZIP_EDIT:
		g_pResEditPrefs->fnNewZip = m_pNewZipEdit->GetData().GetValue().GetFilename();
		break;

	case IDC_DIFF_DISTRI_DESTPATH_EDIT:
		{
			Filename fnDestZip = m_pDestPathEdit->GetData().GetValue().GetFilename();
			g_pResEditPrefs->fnDestZip = fnDestZip;
			g_pResEditPrefs->fnDestZip.SetSuffix("zip");
			if (fnDestZip.Content() && g_pResEditPrefs->fnDestZip != fnDestZip)
				m_pDestPathEdit->SetData(TriState<GeData>(g_pResEditPrefs->fnDestZip));
		}
		break;

	case IDC_OK:
		{
			GeData d;
			String strPassword;
			Int32 lLen = 0;
			char* pchPassword = nullptr;

			Filename fnDestZip = m_pDestPathEdit->GetData().GetValue().GetFilename();
			g_pResEditPrefs->fnNewZip = m_pNewZipEdit->GetData().GetValue().GetFilename();
			g_pResEditPrefs->fnDestZip = fnDestZip;
			g_pResEditPrefs->fnDestZip.SetSuffix("zip");
			if (fnDestZip.Content() && g_pResEditPrefs->fnDestZip != fnDestZip)
				m_pDestPathEdit->SetData(TriState<GeData>(g_pResEditPrefs->fnDestZip));
			GetString(IDC_DIFF_DISTRI_PASSWORD_EDIT, strPassword);

			lLen = strPassword.GetCStringLen(STRINGENCODING_8BIT);
			if (lLen)
			{
				pchPassword = NewMemClear(Char,lLen + 2);
				if (pchPassword)
					strPassword.GetCString(pchPassword, lLen + 1, STRINGENCODING_8BIT);
			}

			if (!g_pResEditPrefs->arOldFiles.GetElementCount())
			{
				GeOutString(GeLoadString(IDS_DIFF_DISTRI_NO_OLD), GEMB_ICONSTOP);
				DeleteMem(pchPassword);
				break;
			}
			if (!g_pResEditPrefs->fnNewZip.Content())
			{
				GeOutString(GeLoadString(IDS_DIFF_DISTRI_NO_NEW), GEMB_ICONSTOP);
				DeleteMem(pchPassword);
				break;
			}
			if (!g_pResEditPrefs->fnDestZip.Content())
			{
				GeOutString(GeLoadString(IDS_DIFF_DISTRI_NO_DEST), GEMB_ICONSTOP);
				DeleteMem(pchPassword);
				break;
			}

			if (!DiffZipFiles(g_pResEditPrefs->arOldFiles, g_pResEditPrefs->fnNewZip, g_pResEditPrefs->fnDestZip, pchPassword))
				GeOutString(GeLoadString(IDS_DIFF_DISTRI_FAILED, g_pResEditPrefs->fnNewZip.GetString(), g_pResEditPrefs->fnDestZip.GetString()), GEMB_OK | GEMB_ICONEXCLAMATION);
			DeleteMem(pchPassword);
		}
		break;

	case IDC_CANCEL:
		Close();
		break;

	default:
		break;
	}

	return true;
}
Beispiel #3
0
  /// Called from Message() for MSG_DESCRIPTION_COMMAND.
  void OnDescriptionCommand(BaseObject* op, DescriptionCommand* cmdData)
  {
    BaseDocument* doc = op->GetDocument();
    const AutoUndo au(doc);
    const LONG id = cmdData->id[0].id;

    switch (id)
    {
      case NRCONTAINER_PACKUP:
        ToggleProtect(op);
        break;
      case NRCONTAINER_ICON_LOAD:
      {
        if (m_protected) break;

        // Ask the user for an image-file.
        Filename flname;
        flname.SetDirectory(GeGetC4DPath(C4D_PATH_DESKTOP));
        Bool ok = flname.FileSelect(FILESELECTTYPE_IMAGES, FILESELECT_LOAD,
            GeLoadString(IDS_SELECTICON));

        if (ok)
        {
          // Ensure the destination bitmap is allocated.
          if (!m_customIcon)
            m_customIcon = BaseBitmap::Alloc();
          else
            m_customIcon->FlushAll();

          // If it is still null here, allocation failed.
          if (!m_customIcon)
            MessageDialog(GeLoadString(IDS_INFO_OUTOFMEMORY));
          else
          {
            IMAGERESULT res = m_customIcon->Init(flname);
            if (res != IMAGERESULT_OK)
            {
              MessageDialog(IDS_INFO_INVALIDIMAGE);
              BaseBitmap::Free(m_customIcon);
            }
            else
            {
              // Scale the bitmap down to 64x64 pixels.
              BaseBitmap* dest = BaseBitmap::Alloc();
              const LONG size = CONTAINEROBJECT_ICONSIZE;
              dest->Init(size, size);
              m_customIcon->ScaleIt(dest, 256, true, true);
              BaseBitmap::Free(m_customIcon);
              m_customIcon = dest;
            }
          }
        }
        break;
      }
      case NRCONTAINER_ICON_CLEAR:
      {
        if (m_protected) break;
        if (m_customIcon)
        {
          // TODO: We possibly require a flag for removing the icon
          // on the next MSG_GETCUSTOMICON message, because Cinema
          // still references this bitmap.
          BaseBitmap::Free(m_customIcon);
        }
        break;
      }
    }
  }
Beispiel #4
0
Bool PaletteSubDialog::Command(Int32 id,const BaseContainer &msg)
{
	GeDynamicArray<Palette> pals;
    Palette pal;
    Filename fn;
    switch (id)
    {
		case 3:
            switch(msg.GetInt32(BFM_ACTION_VALUE)){
                case ACTION_NEW:
                    pal.SetColor(0, Color(0.f, 0.f, 0.f).SetSource(COLOR_SOURCE_DISPLAY));
                    id = Palette::AddPalette(pal);
                    m_controlsShown = FALSE;
                    LoadPalette(id);
                    SaveSettings();
                    Palette::UpdateAll();
                    return TRUE;
                case ACTION_LOAD:
                    if(fn.FileSelect(FILESELECTTYPE_ANYTHING, FILESELECT_LOAD, "Load")){
                        String s = fn.GetString();
                        if(Palette::LoadASEFile(s, pal)){
                            id = Palette::AddPalette(pal);
                            m_controlsShown = FALSE;
                            LoadPalette(id);
                            SaveSettings();
                            Palette::UpdateAll();
                        }
                    }
                    return TRUE;
                case ACTION_SAVE:
                    if(fn.FileSelect(FILESELECTTYPE_ANYTHING, FILESELECT_SAVE, "Save", "ase")){
                        String s = fn.GetString();
                        Palette::SaveASEFile(s, m_palette);
                    }
                    return TRUE;
                case ACTION_LABEL:
                    ShowControls(!m_showControls);
                    return TRUE;
                    
            }
            if(msg.GetInt32(BFM_ACTION_VALUE) >= ACTION_COUNT){
                m_controlsShown = FALSE;
                LoadPalette(msg.GetInt32(BFM_ACTION_VALUE)-ACTION_COUNT);
                SaveSettings();
            }
            return TRUE;
        case IDC_LAYOUT_DIRECTION:
            m_controlsShown = FALSE;
            LoadPalette(m_paletteID);
            SaveSettings();
            break;
        case IDC_ROWS:
            PaletteLayout();
            SaveSettings();
            break;
        case IDC_LABELCHECKBOX:
            GetBool(m_labelCheckArea, m_showLabel);
            LoadPalette(m_paletteID);
            SaveSettings();
            break;
        case IDC_NAME:
            if(m_nameArea != NULL){
                GetString(m_nameArea, m_palette.m_name);
                Palette::SetPaletteName(m_paletteID, m_palette.m_name);
                LoadPalette(m_paletteID);
            }
            break;
        case IDC_HIDE:
            ShowControls(FALSE);
            break;
        case IDC_SEARCHTEXT:
            PaletteLayout();
            SaveSettings();
            break;
        case IDC_CREATEMATERIAL:
            {
				Bool linkColors;
				GetBool(m_linkColor,linkColors);
                for(Int32 i=m_palette.m_colors.GetCount()-1;i>=0;--i){
                    BaseMaterial *mat = BaseMaterial::Alloc(Mmaterial);
                    String name = "PaletteMaterial";
                    if(m_palette[i].m_name != ""){
                        name = m_palette[i].m_name;
                    }
                    mat->SetName(name);
                    if(mat != nullptr){
                        BaseChannel *chan = mat->GetChannel(CHANNEL_COLOR);
                        if(chan != nullptr){
                            BaseContainer bc;
							if(linkColors){
								bc.SetInt32(BASECHANNEL_SHADERID, PALETTE_SHADER_ID);
								chan->SetData(bc);
								BaseShader *bs = chan->GetShader();
								BaseContainer* data = bs->GetDataInstance();
								data->SetInt32(PALETTESHADER_PALETTE_ID, 1+m_paletteID);
								data->SetInt32(PALETTESHADER_COLOR_ID, 1+i);
							} else {
								// Color Shader ID: 5832
								bc.SetInt32(BASECHANNEL_SHADERID, 5832);
								chan->SetData(bc);
								BaseShader *bs = chan->GetShader();
								BaseContainer* data = bs->GetDataInstance();
								
								data->SetVector(COLORSHADER_COLOR , m_palette.m_colors[i].AsVector());
							}
                            GetActiveDocument()->InsertMaterial(mat);
                            EventAdd();
                        }
                    }
                }
            }
            break;
		default:
			break;
    }
    return GeDialog::Command(id,msg);
}
Beispiel #5
0
/*********************************************************************\
	Function name    : CResEditBrowser::Command
	Description      :
	Created at       : 25.09.01, @ 22:33:39
	Created by       : Thomas Kunert
	Modified by      :
\*********************************************************************/
Bool CResEditBrowser::Command(Int32 lID, const BaseContainer &msg)
{
	switch (lID)
	{
	case IDC_BROWSE_BUTTON: {
		Filename fn = m_strPath;
		AutoAlloc <BrowseFiles> pFiles;
		pFiles->Init(Filename("\\"), false);
		if (!m_strPath.Content())
			fn = GeGetStartupPath() + String("resource");
		if (fn.FileSelect(FILESELECTTYPE_ANYTHING, FILESELECT_DIRECTORY, GeLoadString(IDS_SPECIFY_RES_PATH)))
		{
			m_strPath = fn;
			FillList();
		}
		break;
	}
	case IDC_DIRECTORY_TREE: {
		TreeViewItem* pSelItem = (TreeViewItem*)msg.GetVoid(TREEVIEW_MESSAGE_ITEM);
		Int32 lType = msg.GetInt32(TREEVIEW_MESSAGE_TYPE);
		if (!pSelItem) break;

		if (lType == TREEVIEW_DOUBLECLICK)
		{
			Filename fn = pSelItem->GetData()->GetString(ITEM_PATH_NAME);
			if (fn.CheckSuffix("res"))
			{
				// open the resource file
				if (!g_bWasActive)
				{ CResEditMenu m; m.Execute(nullptr); }
				if (!g_pTreeDialog) break;
				g_pTreeDialog->OpenDialog(fn);
			}
			else if (fn.CheckSuffix("str"))
			{
				CDialogDoc tempDoc;
				tempDoc.LoadGlobalStringTable(m_strPath, pSelItem->GetData()->GetString(TREEVIEW_TEXT));
				CStringtableDialog dlg(&tempDoc, true);
				if (dlg.Open())
				{
					if (GeOutString(GeLoadString(IDS_SAVE_STRINGTABLE), GEMB_YESNO | GEMB_ICONQUESTION) == GEMB_R_YES)
					{
						tempDoc.SaveGlobalStringTable();
					}
				}
			}
			else if (fn.Content())
			{
				// open the file (it may be an image)
				GeExecuteFile(fn);
			}
			return true;
		}
		else if (lType == TREEVIEW_SELCHANGE)
		{
			m_dirText = pSelItem->GetData()->GetString(ITEM_PATH_NAME);
		}

		break;
	}
	};
	return GeDialog::Command(lID, msg);
}