示例#1
0
LuaConsole::LuaConsole(UserInterface *ui, Container* parent)
		: BasicDialog(parent, ButtonFlags::ROLL_UPDOWN | ButtonFlags::CLOSE)
		, m_ui(ui) {
	setTitleText("Lua-Console");
	setButtonText("");

	CellStrip *panel = new CellStrip(this, Orientation::VERTICAL, 2);
	setContent(panel);

	Anchors inputAnchors(Anchor(AnchorType::RIGID, 2));
	m_inputBox = new LuaInputBox(this, panel);
	m_inputBox->setCell(0);
	m_inputBox->setAnchors(inputAnchors);
	m_inputBox->setText("");
	m_inputBox->setAlignment(Alignment::FLUSH_LEFT);
	m_inputBox->setTextPos(Vec2i(3, 3));
	m_inputBox->InputEntered.connect(this, &LuaConsole::onLineEntered);

	int h = int(m_inputBox->getFont()->getMetrics()->getHeight()) * 2;
	panel->setSizeHint(0, SizeHint(-1, h));

	Anchors outputAnchors(Anchor(AnchorType::RIGID, 0));
	m_outputBox = new CodeBox(panel);
	m_outputBox->setCell(1);
	m_outputBox->setAnchors(outputAnchors);
	m_outputBox->setText("");
	m_outputBox->setAlignment(Alignment::NONE);
}
示例#2
0
void MichaelDeque::stabilize_back(Anchor &a)
{
    Node *pLeft, *pRight;
    
    unsigned int const idxLeft  = index( a.idxLeft ) ;
    unsigned int const idxRight = index( a.idxRight ) ;
    
    pLeft = (Node *) idxLeft;
    pRight = (Node *) idxRight;
    
    if ( m_Anchor.load( std::memory_order::memory_order_acquire ) != a )
        return ;
    
    unsigned int idxPrev = index(pRight->m_Links.load(std::memory_order::memory_order_relaxed).idxLeft);
    Node *pPrev = (Node *) idxPrev;
    
    if ( m_Anchor.load( std::memory_order::memory_order_acquire ) != a )
        return ;
    
    Anchor prevLinks = pPrev->m_Links.load(std::memory_order::memory_order_acquire);
    
    
    if (index(prevLinks.idxRight) != idxRight) {
        if (m_Anchor.load(std::memory_order::memory_order_acquire) != a)
            return;
        
        if (!pPrev->m_Links.compare_exchange_strong(prevLinks, Anchor(prevLinks.idxLeft, idxRight), std::memory_order::memory_order_release, std::memory_order::memory_order_relaxed))
            return;
    }
    
    m_Anchor.compare_exchange_weak(a, Anchor(idxLeft, idxRight), std::memory_order::memory_order_release, std::memory_order::memory_order_relaxed);
}
示例#3
0
	bool Init() override
	{
		m_commonGUIStyle = g_commonGUIStyle;
		m_canvas = Utility::MakeRef(new Canvas());

		// Load textures for song select
		m_style = SongSelectStyle::Get(g_application);

		// Split between statistics and selection wheel (in percentage)
		const float screenSplit = 0.4f;

		// Statistics window
		m_statisticsWindow = Ref<SongStatistics>(new SongStatistics(m_style));
		Canvas::Slot* statisticsSlot = m_canvas->Add(m_statisticsWindow.As<GUIElementBase>());
		statisticsSlot->anchor = Anchor(0, 0, screenSplit, 1.0f);
		statisticsSlot->SetZOrder(2);

		// Background
		Panel* background = new Panel();
		background->imageFillMode = FillMode::Fill;
		background->texture = g_application->LoadTexture("bg.png");
		background->color = Color(0.5f);
		Canvas::Slot* bgSlot = m_canvas->Add(background->MakeShared());
		bgSlot->anchor = Anchors::Full;
		bgSlot->SetZOrder(-2);

		LayoutBox* box = new LayoutBox();
		Canvas::Slot* boxSlot = m_canvas->Add(box->MakeShared());
		boxSlot->anchor = Anchor(screenSplit, 0, 1.0f, 1.0f);
		box->layoutDirection = LayoutBox::Vertical;
		{
			m_searchField = Ref<TextInputField>(new TextInputField(m_commonGUIStyle));
			LayoutBox::Slot* searchFieldSlot = box->Add(m_searchField.As<GUIElementBase>());
			searchFieldSlot->fillX = true;
			m_searchField->OnTextUpdated.Add(this, &SongSelect_Impl::OnSearchTermChanged);

			m_selectionWheel = Ref<SelectionWheel>(new SelectionWheel(m_style));
			LayoutBox::Slot* selectionSlot = box->Add(m_selectionWheel.As<GUIElementBase>());
			selectionSlot->fillY = true;
			m_selectionWheel->OnMapSelected.Add(this, &SongSelect_Impl::OnMapSelected);
			m_selectionWheel->OnDifficultySelected.Add(this, &SongSelect_Impl::OnDifficultySelected);
		}

		// Select interface sound
		m_selectSound = g_audio->CreateSample("audio/menu_click.wav");

		// Setup the map database
		m_mapDatabase.AddSearchPath(g_gameConfig.GetString(GameConfigKeys::SongFolder));

		m_mapDatabase.OnMapsAdded.Add(m_selectionWheel.GetData(), &SelectionWheel::OnMapsAdded);
		m_mapDatabase.OnMapsUpdated.Add(m_selectionWheel.GetData(), &SelectionWheel::OnMapsUpdated);
		m_mapDatabase.OnMapsRemoved.Add(m_selectionWheel.GetData(), &SelectionWheel::OnMapsRemoved);
		m_mapDatabase.OnMapsCleared.Add(m_selectionWheel.GetData(), &SelectionWheel::OnMapsCleared);
		m_mapDatabase.StartSearching();

		m_selectionWheel->SelectRandom();

		return true;
	}
示例#4
0
	HudGsPlay::HudGsPlay(Monolith* _game) :
		Hud(_game, nullptr)
	{
		m_velocityLabel = &CreateScreenElement<TextRender>(PixelOffset(80, -20), Anchor(MidMid, this));
		m_targetVelocityLabel = &CreateScreenElement<TextRender>(PixelOffset(80, 20), Anchor(MidMid, this));
	//	m_velocityLabel = &CreateLabel(Vec2(0.25f, -0.1f), "");
	//	m_targetVelocityLabel = &CreateLabel(Vec2(0.25f, 0.f), "");

		m_mainMessageBox = &CreateMessageBox(Vec2(-0.2f, 0.8f), Vec2(0.4f, 0.2f));
	}
示例#5
0
void GoBlock::CheckConsistency() const
{
    SG_ASSERT(Stones().SubsetOf(m_bd.All(Color())));
    SgPoint anchor = Anchor();
    SG_ASSERT(m_bd.Anchor(anchor) == Anchor());
    SgPointSet stones;
    for (GoBoard::StoneIterator it(m_bd, anchor); it; ++it)
        stones.Include(*it);
    SG_ASSERT(Stones() == stones);
}
示例#6
0
		Anchor Anchor::Get(Type type)
		{
			switch(type)
			{
				case TopLeft:
					return Anchor(0.0,0.0);
				case TopRight:
					return Anchor(1.0,0.0);
				case BottomLeft:
					return Anchor(0.0,1.0);
				case BottomRight:
					return Anchor(1.0,1.0);
				case TopCenter:
					return Anchor(0.5,0.0);
				case BottomCenter:
					return Anchor(0.5,1.0);
				case LeftCenter:
					return Anchor(0.0,0.5);
				case RightCenter:
					return Anchor(1.0,0.5);
				case Center:
				default:
					return Anchor(0.5,0.5);
			}
		}
示例#7
0
UnitTest::UnitTest( const char* name, const char* group )
{
  m_Name = name;
  m_Group = group;
  m_Done = false;
  m_Next = Anchor( this );
}
示例#8
0
bool SLine::readProperties(const QDomElement& e)
      {
      if (Element::readProperties(e))
            return true;
      const QString& tag(e.tagName());
      const QString& val(e.text());
      int i = val.toInt();

      if (tag == "tick2")           // obsolete
            __setTick2(score()->fileDivision(i));
      else if (tag == "tick")       // obsolete
            __setTick1(score()->fileDivision(i));
      else if (tag == "Segment") {
            LineSegment* ls = createLineSegment();
            ls->read(e);
            add(ls);
            }
      else if (tag == "track")
            setTrack(i);
      else if (tag == "length")
            setLen(val.toDouble());
      else if (tag == "diagonal")
            setDiagonal(i);
      else if (tag == "anchor")
            setAnchor(Anchor(i));
      else
            return false;
      return true;
      }
示例#9
0
bool SLine::readProperties(XmlReader& e)
      {
      const QStringRef& tag(e.name());

      if (tag == "tick2")           // obsolete
            __setTick2(score()->fileDivision(e.readInt()));
      else if (tag == "tick")       // obsolete
            __setTick1(score()->fileDivision(e.readInt()));
      else if (tag == "Segment") {
            LineSegment* ls = createLineSegment();
            ls->read(e);
            add(ls);
            }
      else if (tag == "length")
            setLen(e.readDouble());
      else if (tag == "diagonal")
            setDiagonal(e.readInt());
      else if (tag == "anchor")
            setAnchor(Anchor(e.readInt()));
      else if (Element::readProperties(e))
            ;
      else
            return false;
      return true;
      }
示例#10
0
	void EmitFromEvents::EmitProps(const std::string& tag, anchor_t anchor)
	{
		if(!tag.empty() && tag != "?")
			m_emitter << VerbatimTag(tag);
		if(anchor)
			m_emitter << Anchor(ToString(anchor));
	}
示例#11
0
MenuStateGraphicInfo::MenuStateGraphicInfo(Program &program, MainMenu *mainMenu)
		: MenuState(program, mainMenu) {
	Lang &lang= Lang::getInstance();
	Renderer &renderer = Renderer::getInstance();

	string glInfo = renderer.getGlInfo();
	string glExt = renderer.getGlMoreInfo();
	string glExt2 = renderer.getGlMoreInfo2();

	WidgetConfig &cfg = g_widgetConfig;

	int itemHeight = cfg.getDefaultItemHeight();

	CellStrip *rootStrip = new CellStrip((Container*)&program, Orientation::VERTICAL, 2);
	rootStrip->setSizeHint(0, SizeHint());
	rootStrip->setSizeHint(1, SizeHint(-1, itemHeight * 3));
	Vec2i pad(15, 25);
	rootStrip->setPos(pad);
	rootStrip->setSize(Vec2i(g_config.getDisplayWidth() - pad.w * 2, g_config.getDisplayHeight() - pad.h * 2));

	Anchors centreAnchors;
	centreAnchors.setCentre(true, true);
	Anchors fillAnchors(Anchor(AnchorType::RIGID, 0));

	CellStrip *mainStrip = new CellStrip(rootStrip, Orientation::HORIZONTAL, 3);
	mainStrip->setCell(0);
	mainStrip->setAnchors(fillAnchors);

	Widgets::StaticText* l_text = new Widgets::StaticText(mainStrip);
	l_text->setCell(0);
	l_text->setAnchors(fillAnchors);
	l_text->setText(glInfo);

	ScrollText* l_stext = new ScrollText(mainStrip);
	l_stext->setCell(1);
	l_stext->setAnchors(fillAnchors);
	l_stext->setText(glExt);

	l_stext = new ScrollText(mainStrip);
	l_stext->setCell(2);
	l_stext->setAnchors(fillAnchors);
	l_stext->setText(glExt2);

	// buttons panel
	CellStrip *btnPanel = new CellStrip(rootStrip, Orientation::HORIZONTAL, 3);
	btnPanel->setCell(1);
	btnPanel->setAnchors(fillAnchors);

	// create buttons
	Vec2i sz(itemHeight * 7, itemHeight);
	Button* l_button = new Button(btnPanel, Vec2i(0), sz);
	l_button->setCell(0);
	l_button->setAnchors(centreAnchors);
	l_button->setText(lang.get("Return"));
	l_button->Clicked.connect(this, &MenuStateGraphicInfo::onButtonClick);

	program.setFade(0.f);
}
示例#12
0
Wt::WWidget *Navigation::anchor()
{
  Wt::WTemplate *result = new TopicTemplate("navigation-anchor");

  result->bindWidget("Anchor", Anchor());
  result->bindWidget("AnchorImage", AnchorImage());

  return result;
}
示例#13
0
MenuStateOptions::MenuStateOptions(Program &program, MainMenu *mainMenu)
		: MenuState(program, mainMenu)
		, m_transitionTarget(Transition::INVALID) {
	Lang &lang= Lang::getInstance();
	Config &config= Config::getInstance();
	const Metrics &metrics = Metrics::getInstance();

	int s = g_widgetConfig.getDefaultItemHeight();

	CellStrip *rootStrip = new CellStrip((Container*)&program, Orientation::VERTICAL, 2);
	Vec2i pad(15, 25);
	rootStrip->setPos(pad);
	rootStrip->setSize(Vec2i(g_config.getDisplayWidth() - pad.w * 2, g_config.getDisplayHeight() - pad.h * 2));

	// Option panel
	rootStrip->setSizeHint(0, SizeHint());
	// need to keep Options instance alive to use callbacks
	m_options = new Options(rootStrip, this);
	m_options->setCell(0);
	m_options->setPos(pad);
	m_options->setSize(Vec2i(g_config.getDisplayWidth() - pad.w * 2, g_config.getDisplayHeight()));
	//m_options->setSizeHint(0, SizeHint(-1, s));
	//m_options->setSizeHint(1, SizeHint(-1, 1000));

	Anchors anchors(Anchor(AnchorType::RIGID, 0));

	// Buttons panel
	rootStrip->setSizeHint(1, SizeHint(-1, s * 3));
	CellStrip *btnPanel = new CellStrip(rootStrip, Orientation::HORIZONTAL, 3);
	btnPanel->setCell(1);
	btnPanel->setAnchors(anchors);

	anchors.setCentre(true, true);
	Vec2i sz(s * 7, s);

	// create buttons
	m_returnButton = new Button(btnPanel, Vec2i(0), sz);
	m_returnButton->setCell(0);
	m_returnButton->setAnchors(anchors);
	m_returnButton->setText(lang.get("Return"));
	m_returnButton->Clicked.connect(this, &MenuStateOptions::onButtonClick);

	m_autoConfigButton = new Button(btnPanel, Vec2i(0), sz);
	m_autoConfigButton->setCell(1);
	m_autoConfigButton->setAnchors(anchors);
	m_autoConfigButton->setText(lang.get("AutoConfig"));
	m_autoConfigButton->Clicked.connect(this, &MenuStateOptions::onButtonClick);
	
	m_openGlInfoButton = new Button(btnPanel, Vec2i(0), sz);
	m_openGlInfoButton->setCell(2);
	m_openGlInfoButton->setAnchors(anchors);
	m_openGlInfoButton->setText(lang.get("GraphicInfo"));
	m_openGlInfoButton->Clicked.connect(this, &MenuStateOptions::onButtonClick);

	program.setFade(0.f);
}
示例#14
0
bool GoBlock::AllEmptyAreLiberties(const SgPointSet& area) const
{
    const SgPoint anchor = Anchor();
    for (SgSetIterator it(area); it; ++it)
        if (  m_bd.IsEmpty(*it)
           && ! m_bd.IsLibertyOfBlock(*it, anchor)
           )
            return false;
    return true;
}
示例#15
0
PlayerSlotWidget::PlayerSlotWidget(Container* parent)
    : CellStrip(parent, Orientation::HORIZONTAL, Origin::CENTRE, 5)
    , m_freeSlot(false) {
    setWidgetStyle(WidgetType::STATIC_WIDGET);
    Anchors anchors(Anchor(AnchorType::RIGID, 3), Anchor(AnchorType::RIGID, 0));
    //Anchors anchors(Anchor(AnchorType::RIGID, 0));
    int hints[] = { 18, 33, 33, 8, 8 };
    setPercentageHints(hints);

    m_label = new StaticText(this);
    m_label->setCell(0);
    m_label->setText("Player #");
    m_label->setAnchors(anchors);

    m_controlList = new DropList(this);
    m_controlList->setCell(1);
    m_controlList->setAnchors(anchors);

    foreach_enum (ControlType, ct) {
        m_controlList->addItem(g_lang.get(ControlTypeNames[ct]));
    }
示例#16
0
int MichaelDeque::pop_front() {
    
    Anchor a;
    
    while (true) {
        a = m_Anchor.load(std::memory_order::memory_order_acquire);
        
        if (c_nEmptyIndex == a.idxLeft) {
            return -1;
        }
        
        if (a.idxRight == a.idxLeft) {
            if (m_Anchor.compare_exchange_weak(a, Anchor(c_nEmptyIndex, c_nEmptyIndex), std::memory_order::memory_order_release, std::memory_order::memory_order_relaxed))
                break;
        } else if (Stable == status(a)) {
            unsigned int idxLeft = index(a.idxLeft), idxRight = index(a.idxRight);
            Node *pLeft, *pRight;
            pLeft = (Node*) idxLeft;
            pRight = (Node*) idxRight;
            
            if (m_Anchor.load(std::memory_order::memory_order_acquire) != a) {
                continue;
            }
            
            unsigned int nPrev = pLeft->m_Links.load(std::memory_order::memory_order_acquire).idxRight;
            if (m_Anchor.compare_exchange_weak(a, Anchor(nPrev, a.idxRight), std::memory_order::memory_order_release, std::memory_order::memory_order_relaxed))
                //return pRight->data;
                break;
        } else {
            stabilize(a);
        }
    }
    
    if (a.idxLeft != c_nEmptyIndex){
        Node *res = (Node*) index(a.idxLeft);
        return res->data;
    }
    
    return -1;
}
示例#17
0
void MichaelDeque::push_back( int& data) {
    
    Node* node = new Node();
    node->data = data;
    
    while (1) {
        Anchor a = m_Anchor.load(std::memory_order::memory_order_acquire);
        if (a.idxRight == c_nEmptyIndex) {
            if (m_Anchor.compare_exchange_weak(a, Anchor((int) node | c_nEmptyIndex, (int) node | c_nEmptyIndex), std::memory_order::memory_order_release, std::memory_order::memory_order_relaxed))
                break;
        } else if ( Stable == status(a)) {
            node->m_Links.store(Anchor(a.idxRight, c_nEmptyIndex), std::memory_order::memory_order_release);
            Anchor aNew(a.idxLeft, (int) node | c_nFlagMask);
            if (m_Anchor.compare_exchange_weak(a, aNew, std::memory_order::memory_order_release, std::memory_order::memory_order_relaxed)) {
                stabilize_back(aNew);
                break;
            }
        } else {
            stabilize(a);
        }
    }
}
void ServerAnchorList::SetAnchor(const std::string& name, const BufferPtr& data)
{
	// Overwrite the anchor with the given name OR create a new anchor with the name
	XStringPtr nameXString = new XString(name);

	ObjectElementPtr newAnchorElement = ObjectElement::Cast(GetObjectElement()->GetElement(nameXString));
	if (newAnchorElement == nullptr)
	{
		newAnchorElement = GetObjectElement()->CreateObjectElement(nameXString);
	}

	m_anchors[name] = Anchor(newAnchorElement, data);
}
示例#19
0
	void			Track(float x, float y )
	{
		float angle;
		CartesianToAngle(x, y, angle );

		//RGBColor color = {65535,65535,65535};
		Draw(sBackgroundColor);
				
		lastx = x;
		lasty = y;
		lastAngle = angle;

		Anchor();
		
		Draw(mColor);
	};
FReply FCurveColorCustomization::OnCurvePreviewDoubleClick(const FGeometry& InMyGeometry, const FPointerEvent& InMouseEvent)
{
	if (InMouseEvent.GetEffectingButton() == EKeys::LeftMouseButton)
	{
		if (RuntimeCurve->ExternalCurve)
		{
			FAssetEditorManager::Get().OpenEditorForAsset(RuntimeCurve->ExternalCurve);
		}
		else
		{
			DestroyPopOutWindow();

			// Determine the position of the window so that it will spawn near the mouse, but not go off the screen.
			const FVector2D CursorPos = FSlateApplication::Get().GetCursorPos();
			FSlateRect Anchor(CursorPos.X, CursorPos.Y, CursorPos.X, CursorPos.Y);

			FVector2D AdjustedSummonLocation = FSlateApplication::Get().CalculatePopupWindowPosition( Anchor, FCurveColorCustomization::DEFAULT_WINDOW_SIZE, Orient_Horizontal );

			TSharedPtr<SWindow> Window = SNew(SWindow)
				.Title( FText::Format( LOCTEXT("WindowHeader", "{0} - Internal Color Curve Editor"), StructPropertyHandle->GetPropertyDisplayName()) )
				.ClientSize( FCurveColorCustomization::DEFAULT_WINDOW_SIZE )
				.ScreenPosition(AdjustedSummonLocation)
				.AutoCenter(EAutoCenter::None)
				.SupportsMaximize(false)
				.SupportsMinimize(false)
				.SizingRule( ESizingRule::FixedSize );

			// init the mini curve editor widget
			TSharedRef<SMiniCurveEditor> MiniCurveEditor =
				SNew(SMiniCurveEditor)
				.CurveOwner(this)
				.OwnerObject(Owner)
				.ParentWindow(Window);

			Window->SetContent( MiniCurveEditor );

			// Find the window of the parent widget
			FWidgetPath WidgetPath;
			FSlateApplication::Get().GeneratePathToWidgetChecked( CurveWidget.ToSharedRef(), WidgetPath );
			Window = FSlateApplication::Get().AddWindowAsNativeChild( Window.ToSharedRef(), WidgetPath.GetWindow() );

			//hold on to the window created for external use...
			CurveEditorWindow = Window;
		}
	}
	return FReply::Handled();
}
示例#21
0
 void ContourAnchors(const uint16_t * src, size_t srcStride, size_t width, size_t height, 
     size_t step, int16_t threshold, uint8_t * dst, size_t dstStride)
 {
     memset(dst, 0, width);
     memset(dst + dstStride*(height - 1), 0, width);
     dst += dstStride;
     src += srcStride;
     for(size_t row = 1; row < height - 1; row += step)
     {
         dst[0] = 0;
         for(size_t col = 1; col < width - 1; ++col)
             dst[col] = Anchor(src + col, srcStride, threshold);
         dst[width - 1] = 0;
         dst += step*dstStride;
         src += step*srcStride;
     }
 }
示例#22
0
const char* UnitTest::FindNextGroup( const char* last_group )
{
  const char* best = NULL;
  UnitTest* UnitTest = Anchor();
  while( UnitTest )
  {
    if( !UnitTest->m_Done )
    {
      bool higher_than_last = !last_group || strcmp( UnitTest->m_Group, last_group ) > 0;
      bool lower_than_best = !best || strcmp( UnitTest->m_Group, best ) < 0;
      if( higher_than_last && lower_than_best )
      {
        best = UnitTest->m_Group;
      }
    }
    UnitTest = UnitTest->m_Next;
  }
  return best;
}
示例#23
0
	Emitter& operator << (Emitter& out, const Node& node)
	{
		// write anchor/alias
		if(node.m_anchor != "") {
			if(node.m_alias)
				out << Alias(node.m_anchor);
			else
				out << Anchor(node.m_anchor);
		}

		// TODO: write tag

		// write content
		if(node.m_pContent)
			node.m_pContent->Write(out);
		else if(!node.m_alias)
			out << Null;

		return out;
	}
示例#24
0
void ScanForFunctions(CLanguageProxy& proxy)
{
	const char *text = proxy.Text(), *max = text + proxy.Size();
	if (*max != 0)
		return;
	
	while (text < max)
	{
		text = skip(text, '<');
		text = skip_white(text);
		
		switch (toupper(*text))
		{
			case 0:
				return;
			case 'A':
				if (isspace(*++text))
					text = Anchor(text, proxy);
				else
					text = skip_nc(text, '>');
				break;
			case 'H':
				if (*++text >= '1' && *text <= '6')
				{
					text = Heading(text, proxy);
				}
				else
					text = skip_nc(text, '>');
				break;
			case 'S':
				if (strncasecmp(text, "SCRIPT", 6) == 0)
					text = JavaScript(text, proxy);
				break;
			default:
				text = skip_nc(text + 1, '>');
				break;
		}
	}
} /* ScanForFunctions */
示例#25
0
UnitTest* UnitTest::FindNext( const char* group, const UnitTest* last_done )
{
  UnitTest* best = NULL;
  UnitTest* test = Anchor();
  while( test )
  {
    if( !test->m_Done )
    {
      if( !group || !strcmp( group, test->m_Group ) )
      {
        bool higher_than_last = !last_done || strcmp( test->m_Name, last_done->m_Name ) > 0;
        bool lower_than_best = !best || strcmp( test->m_Name, best->m_Name ) < 0;
        if( higher_than_last && lower_than_best )
        {
          best = test;
        }
      }
    }
    test = test->m_Next;
  }
  return best;
}
示例#26
0
PlayerSlotLabels::PlayerSlotLabels(Container* parent)
    : CellStrip(parent, Orientation::HORIZONTAL, Origin::CENTRE, 5) {
    setWidgetStyle(WidgetType::STATIC_WIDGET);
    CoreData &coreData = CoreData::getInstance();
    Anchors anchors(Anchor(AnchorType::RIGID, 0));
    int hints[] = { 18, 33, 33, 8, 8 };
    setPercentageHints(hints);

    StaticText *label = new StaticText(this);
    label->setCell(0);
    label->setText(g_lang.get("Player"));
    label->setShadow(Vec4f(0.f, 0.f, 0.f, 1.f));
    label->setAnchors(anchors);

    label = new StaticText(this);
    label->setCell(1);
    label->setText(g_lang.get("Control"));
    label->setShadow(Vec4f(0.f, 0.f, 0.f, 1.f));
    label->setAnchors(anchors);

    label = new StaticText(this);
    label->setCell(2);
    label->setText(g_lang.get("Faction"));
    label->setShadow(Vec4f(0.f, 0.f, 0.f, 1.f));
    label->setAnchors(anchors);

    label = new StaticText(this);
    label->setCell(3);
    label->setText(g_lang.get("Team"));
    label->setShadow(Vec4f(0.f, 0.f, 0.f, 1.f));
    label->setAnchors(anchors);

    label = new StaticText(this);
    label->setCell(4);
    label->setText(g_lang.get("Colour"));
    label->setShadow(Vec4f(0.f, 0.f, 0.f, 1.f));
    label->setAnchors(anchors);
}
示例#27
0
void GoChain::WriteID(std::ostream& stream) const
{
    stream << ' '<< SgBW(Color()) << " GoChain "
           << SgWritePoint(Anchor());
}
示例#28
0
	void HudGsPlay::BuildScriptVars()
	{
		for (auto var : m_scriptVars)
		{
			m_scriptDisplays.push_back(&CreateScreenElement<FillBar>(PixelOffset(50, 100), PixelOffset(300, 30), DefinitionPoint::BotLeft, Anchor(BotLeft, this)));
		}
	}
示例#29
0
void SymbolBucket::addFeature(const std::vector<std::vector<Coordinate>> &lines,
        const Shaping &shapedText, const PositionedIcon &shapedIcon, const GlyphPositions &face) {

    const float minScale = 0.5f;
    const float glyphSize = 24.0f;

    const float fontScale = layout.text.size / glyphSize;
    const float textBoxScale = tilePixelRatio * fontScale;
    const float textMaxBoxScale = tilePixelRatio * layout.textMaxSize / glyphSize;
    const float iconBoxScale = tilePixelRatio * layout.icon.size;
    const float symbolSpacing = tilePixelRatio * layout.spacing;
    const bool avoidEdges = layout.avoidEdges && layout.placement != PlacementType::Line;
    const float textPadding = layout.text.padding * tilePixelRatio;
    const float iconPadding = layout.icon.padding * tilePixelRatio;
    const float textMaxAngle = layout.text.maxAngle * M_PI / 180;
    const bool textAlongLine =
        layout.text.rotationAlignment == RotationAlignmentType::Map &&
        layout.placement == PlacementType::Line;
    const bool iconAlongLine =
        layout.icon.rotationAlignment == RotationAlignmentType::Map &&
        layout.placement == PlacementType::Line;
    const bool mayOverlap = layout.text.allowOverlap || layout.icon.allowOverlap ||
        layout.text.ignorePlacement || layout.icon.ignorePlacement;
    const bool isLine = layout.placement == PlacementType::Line;
    const float textRepeatDistance = symbolSpacing / 2;

    auto& clippedLines = isLine ?
        util::clipLines(lines, 0, 0, 4096, 4096) :
        lines;

    for (const auto& line : clippedLines) {
        if (line.empty()) continue;

        // Calculate the anchor points around which you want to place labels
        Anchors anchors = isLine ?
            getAnchors(line, symbolSpacing, textMaxAngle, shapedText.left, shapedText.right, shapedIcon.left, shapedIcon.right, glyphSize, textMaxBoxScale, overscaling) :
            Anchors({ Anchor(float(line[0].x), float(line[0].y), 0, minScale) });

        // For each potential label, create the placement features used to check for collisions, and the quads use for rendering.
        for (Anchor &anchor : anchors) {
            if (shapedText && isLine) {
                if (anchorIsTooClose(shapedText.text, textRepeatDistance, anchor)) {
                    continue;
                }
            }

            const bool inside = !(anchor.x < 0 || anchor.x > 4096 || anchor.y < 0 || anchor.y > 4096);

            if (avoidEdges && !inside) continue;

            // Normally symbol layers are drawn across tile boundaries. Only symbols
            // with their anchors within the tile boundaries are added to the buffers
            // to prevent symbols from being drawn twice.
            //
            // Symbols in layers with overlap are sorted in the y direction so that
            // symbols lower on the canvas are drawn on top of symbols near the top.
            // To preserve this order across tile boundaries these symbols can't
            // be drawn across tile boundaries. Instead they need to be included in
            // the buffers for both tiles and clipped to tile boundaries at draw time.
            //
            // TODO remove the `&& false` when is #1673 implemented
            const bool addToBuffers = (mode == MapMode::Still) || inside || (mayOverlap && false);

            symbolInstances.emplace_back(anchor, line, shapedText, shapedIcon, layout, addToBuffers,
                    textBoxScale, textPadding, textAlongLine,
                    iconBoxScale, iconPadding, iconAlongLine,
                    face);
        }
    }
}
示例#30
0
	void SelectMap(int32 newIndex)
	{
		Set<MapIndex*> visibleMaps;
		auto& srcCollection = m_SourceCollection();
		auto it = srcCollection.find(newIndex);
		if(it != srcCollection.end())
		{
			const float initialSpacing = 0.65f * m_style->frameMain->GetSize().y;
			const float spacing = 0.8f * m_style->frameSub->GetSize().y;
			const Anchor anchor = Anchor(0.0f, 0.5f, 1.0f, 0.5f);

			static const int32 numItems = 10;

			int32 istart;
			for(istart = 0; istart > -numItems;)
			{
				if(it == srcCollection.begin())
					break;
				it--;
				istart--;
			}

			for(int32 i = istart; i <= numItems; i++)
			{
				if(it != srcCollection.end())
				{
					visibleMaps.Add(it->second);

					// Add a new map slot
					bool newItem = m_guiElements.find(it->second) == m_guiElements.end();
					Ref<SongSelectItem> item = m_GetMapGUIElement(it->second);
					float offset = 0;
					if(i != 0)
					{
						offset = initialSpacing * Math::Sign(i) +
							spacing * (i - Math::Sign(i));
					}
					Canvas::Slot* slot = Add(item.As<GUIElementBase>());

					int32 z = -abs(i);
					slot->SetZOrder(z);

					slot->anchor = anchor;
					slot->autoSizeX = true;
					slot->autoSizeY = true;
					slot->alignment = Vector2(0, 0.5f);
					if(newItem)
					{
						// Hard set target position
						slot->offset.pos = Vector2(0, offset);
						slot->offset.size.x = z * 50.0f;
					}
					else
					{
						// Animate towards target position
						item->AddAnimation(Ref<IGUIAnimation>(
							new GUIAnimation<Vector2>(&slot->offset.pos, Vector2(0, offset), 0.1f)), true);
						item->AddAnimation(Ref<IGUIAnimation>(
							new GUIAnimation<float>(&slot->offset.size.x, z * 50.0f, 0.1f)), true);
					}

					item->fade = 1.0f - ((float)abs(i) / (float)numItems);
					item->innerOffset = item->fade * 100.0f;

					if(i == 0)
					{
						m_OnMapSelected(it->second);
					}

					it++;
				}
			}
		}
		m_currentlySelectedId = newIndex;

		// Cleanup invisible elements
		for(auto it = m_guiElements.begin(); it != m_guiElements.end();)
		{
			if(!visibleMaps.Contains(it->first))
			{
				Remove(it->second.As<GUIElementBase>());
				it = m_guiElements.erase(it);
				continue;
			}
			it++;
		}
	}