Ejemplo n.º 1
0
void
MagicView::SetFocusModelView(int f)
{
   if (view_mode == VIEW_ALL) {
      view_focus = f;

      for (int row = 0; row < 2; row++) {
         for (int col = 0; col < 2; col++) {
            int index = 2*row + col;

            ActiveWindow* win = view_win[index];

            win->Show();
            win->SetCells(col, row, 1, 1);
            win->SetCellInsets(Insets(1,1,1,1));

            if (index == view_focus) {
               win->SetStyle(WIN_WHITE_FRAME);
            }
            else {
               win->SetStyle(WIN_BLACK_FRAME);
            }
         }
      }
   }
   else if (IsUVEdit()) {
      view_focus = view_mode;
   }
   else {
      view_mode  = f;
      view_focus = f;

      for (int i = 0; i < 4; i++) {
         ActiveWindow* win = view_win[i];

         if (i == view_mode) {
            win->Show();
            win->SetCells(0,0,2,2);
            win->SetStyle(WIN_WHITE_FRAME);
         }

         else {
            win->Hide();
            win->SetCells(0,0,0,0);
            win->SetStyle(WIN_BLACK_FRAME);
         }
      }
   }

   main_win->DoLayout();
}
void
FormWindow::CreateDefLabel(CtrlDef& def)
{
	ActiveWindow* ctrl = CreateLabel(def.GetText(),
	def.GetX(),
	def.GetY(),
	def.GetW(),
	def.GetH(),
	def.GetID(),
	def.GetParentID(),
	def.GetStyle());

	ctrl->SetAltText(def.GetAltText());
	ctrl->SetBackColor(def.GetBackColor());
	ctrl->SetForeColor(def.GetForeColor());
	ctrl->SetTextAlign(def.GetTextAlign());
	ctrl->SetSingleLine(def.GetSingleLine());
	ctrl->SetTransparent(def.GetTransparent());
	ctrl->SetHidePartial(def.GetHidePartial());

	ctrl->SetMargins(def.GetMargins());
	ctrl->SetTextInsets(def.GetTextInsets());
	ctrl->SetCellInsets(def.GetCellInsets());
	ctrl->SetCells(def.GetCells());
	ctrl->SetFixedWidth(def.GetFixedWidth());
	ctrl->SetFixedHeight(def.GetFixedHeight());

	ctrl->UseLayout(def.GetLayout().x_mins,
	def.GetLayout().y_mins,
	def.GetLayout().x_weights,
	def.GetLayout().y_weights);

	if (def.GetTexture().length() > 0) {
		Bitmap*     ctrl_tex = 0;
		DataLoader* loader   = DataLoader::GetLoader();
		loader->SetDataPath("Screens/");
		loader->LoadTexture(def.GetTexture(), ctrl_tex);
		loader->SetDataPath("");

		ctrl->SetTexture(ctrl_tex);
	}

	Font* f = FontMgr::Find(def.GetFont());
	if (f) ctrl->SetFont(f);
}
Ejemplo n.º 3
0
void
MagicView::SetupModelViews()
{
   switch (view_mode) {
   case VIEW_ALL: {
         for (int row = 0; row < 2; row++) {
            for (int col = 0; col < 2; col++) {
               int index = 2*row + col;

               ActiveWindow* win = view_win[index];

               win->Show();
               win->SetCells(col, row, 1, 1);
               win->SetCellInsets(Insets(1,1,1,1));
            }
         }

         uvmap_win->Hide();
         uvmap_win->SetCells(0,0,0,0);
      }
      break;

   case VIEW_TOP:
   case VIEW_SIDE:
   case VIEW_FRONT:
   case VIEW_PERSPECTIVE: {
         view_focus = view_mode;

         for (int i = 0; i < 4; i++) {
            ActiveWindow* win = view_win[i];

            if (i == view_mode) {
               win->Show();
               win->SetCells(0,0,2,2);
               win->SetStyle(WIN_WHITE_FRAME);
            }

            else {
               win->Hide();
               win->SetCells(0,0,0,0);
               win->SetStyle(WIN_BLACK_FRAME);
            }
         }

         uvmap_win->Hide();
         uvmap_win->SetCells(0,0,0,0);
      }
      break;

   case VIEW_UV_MAP: {
         view_focus = view_mode;

         for (int i = 0; i < 4; i++) {
            ActiveWindow* win = view_win[i];
            win->Hide();
            win->SetCells(0,0,0,0);
            win->SetStyle(WIN_BLACK_FRAME);
         }

         uvmap_win->Show();
         uvmap_win->SetCells(0,0,2,2);
      }
      break;

   default:
      break;
   }

   main_win->DoLayout();
}
Ejemplo n.º 4
0
void MagicView::OnInitialUpdate() 
{
	CView::OnInitialUpdate();
   Color::SetPalette(standard_palette, 256, inverse_palette);

   if (!video_settings)
      video_settings = new VideoSettings;

   GetClientRect(&client_rect);

   // Use client area to set video window size
   int w = client_rect.right - client_rect.left;
   int h = client_rect.bottom - client_rect.top;

   video_settings->is_windowed   = true;
   video_settings->window_width  = w;
   video_settings->window_height = h;

   if (!video) {
      video = new VideoDX9(GetSafeHwnd(), video_settings);
      *video_settings = *video->GetVideoSettings();

      if (video) {
         Color::UseVideo(video);
         video->UseXFont("System", 12, false, false);

         screen = new Screen(video);
         if (!screen) {
            ::Print("ERROR: Could not create Screen object.\n");
            return;
         }

         ::Print("  Created screen object (%d x %d).\n", w, h);
   
         if (!screen->SetBackgroundColor(Color::Black))
            ::Print("  WARNING: could not set video background color to Black\n");

         screen->ClearAllFrames(true);

         ::Print("  Established requested video parameters.\n");
         ::Print("  ---------------------------------------\n\n");

         if (!scene) {
            scene = new Scene;

            scene->SetAmbient(Color(60,60,60));

            Point light_pos(3e6, 5e6, 4e6);

            main_light = new Light(1.0f); //1.25f);
            main_light->MoveTo(light_pos);
            main_light->SetType(Light::LIGHT_DIRECTIONAL);
            main_light->SetColor(Color::White);
            main_light->SetShadow(true);

            scene->AddLight(main_light);

            back_light = new Light(0.5f);
            back_light->MoveTo(light_pos * -1);
            back_light->SetType(Light::LIGHT_DIRECTIONAL);
            back_light->SetColor(Color::White);

            scene->AddLight(back_light);

            Selection*  seln     = GetDocument()->GetSelection();
            Selector*   selector = GetDocument()->GetSelector();

            if (seln && selector) {
               scene->Graphics().clear();
               scene->AddGraphic(seln);
               scene->AddGraphic(selector);

               selector->UseModel(0);
            }
         }

         int   mins[2]     = { 0, 0 };
         float weights[2]  = { 1, 1 };

         main_win = new ActiveWindow(screen, 0, 0, w, h, 100, 0);
         main_win->UseLayout(2, 2, mins, mins, weights, weights);
         main_win->SetBackColor(Color::Gray);

         screen->AddWindow(main_win);

         DWORD view_types[] = { 
            ModelView::VIEW_PLAN,
            ModelView::VIEW_PROJECT,
            ModelView::VIEW_SIDE,
            ModelView::VIEW_FRONT
         };

         for (int row = 0; row < 2; row++) {
            for (int col = 0; col < 2; col++) {
               int index = 2*row + col;

               ActiveWindow* win = new ActiveWindow(screen, 
                                                    col*w/2, 
                                                    row*h/2, 
                                                    w/2, 
                                                    h/2, 
                                                    101+index, 
                                                    WIN_BLACK_FRAME, 
                                                    main_win);

               win->SetCells(col, row, 1, 1);
               win->SetCellInsets(Insets(1,1,1,1));
               win->SetBackColor(Color(160,160,160));

               ModelView* mv = new ModelView(win, scene, view_types[index]);

               if (view_types[index] == ModelView::VIEW_PROJECT)
                  mv->SetFillMode(ModelView::FILL_TEXTURE);

               mv->UseGrid(grid);
               win->AddView(mv);

               view_win[index]   = win;
               model_view[index] = mv;
            }
         }

         view_win[0]->SetStyle(WIN_WHITE_FRAME);

         uvmap_win  = new ActiveWindow(screen, 0, 0, w, h, 110, WIN_BLACK_FRAME, main_win);
         uvmap_view = new UVMapView(uvmap_win);
         uvmap_win->AddView(uvmap_view);

         main_win->DoLayout();
      }

      else {
         ::Print("  Could not establish requested video parameters.\n");
         ::Print("  -----------------------------------------------\n\n");
      }
   }
}