• R/O
  • HTTP
  • SSH
  • HTTPS

コミット

タグ

よく使われているワード(クリックで追加)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Adjustor mod plugin for VS


コミットメタ情報

リビジョン5a362bba54a7e35b856c6bb5285b898f6320f8c1 (tree)
日時2019-06-07 05:53:47
作者melchior <melchior@user...>
コミッターmelchior

ログメッセージ

Item condition loss only when change made
Tool mode icons
Version incriment

変更サマリ

差分

--- a/AdjustorMod/ItemAdjustor.cs
+++ b/AdjustorMod/ItemAdjustor.cs
@@ -172,6 +172,7 @@ namespace Adjustor
172172 }
173173
174174 if (api.Side.IsServer( )) {
175+ bool madeAdjustment = false;
175176
176177 BlockPos position = blockSel.Position;
177178 Block thatBlock = byEntity.World.BlockAccessor.GetBlock(position);
@@ -189,18 +190,17 @@ namespace Adjustor
189190
190191 EnumWorldAccessResponse why = ServerApi.World.Claims.TestAccess(thePlayer, position, EnumBlockAccessFlags.BuildOrBreak);
191192 if (why != EnumWorldAccessResponse.Granted) {
192- ServerApi.SendMessage(thePlayer, GlobalConstants.CurrentChatGroup, string.Format("Not permitted, {0}", why.ToString( )), EnumChatType.Notification);
193+ ServerApi.SendMessage(thePlayer, GlobalConstants.CurrentChatGroup, string.Format("Not permitted, {0}", why), EnumChatType.Notification);
193194 return false;
194195 }
195196
196197 if (this.CurrentRotationMode(slot) == RotationModes.Free) {
197- FreeRotation(blockSel, byEntity, thePlayer, thatBlock, position);
198+ madeAdjustment = FreeRotation(blockSel, byEntity, thePlayer, thatBlock, position);
198199 } else {
199- FixedRotation(this.CurrentRotationMode(slot),blockSel, byEntity, thePlayer, thatBlock, position);
200+ madeAdjustment = FixedRotation(this.CurrentRotationMode(slot),blockSel, byEntity, thePlayer, thatBlock, position);
200201 }
201202
202-
203- DamageItem(ServerApi.World, byEntity, slot);
203+ if (madeAdjustment) DamageItem(ServerApi.World, byEntity, slot);
204204
205205 return secondsUsed < 0.7;
206206 }
@@ -249,39 +249,7 @@ namespace Adjustor
249249 {
250250 RotationModes rotateMode = ( RotationModes )toolMode;
251251
252- switch (rotateMode) {
253- case RotationModes.Free:
254- DrawTextGlyph(cr, x, y, width, height, color, Lang.GetMatching("adjustor:rotation-free").ToUpperInvariant( ));
255- break;
256-
257- case RotationModes.Up:
258- DrawTextGlyph(cr, x, y, width, height, color, Lang.GetMatching("adjustor:rotation-up").ToUpperInvariant( ));
259- break;
260-
261- case RotationModes.Down:
262- DrawTextGlyph(cr, x, y, width, height, color, Lang.GetMatching("adjustor:rotation-down").ToUpperInvariant( ));
263- break;
264-
265- case RotationModes.North:
266- DrawTextGlyph(cr, x, y, width, height, color, Lang.GetMatching("facing-north" ).ToUpperInvariant() );
267- break;
268-
269- case RotationModes.East:
270- DrawTextGlyph(cr, x, y, width, height, color, Lang.GetMatching("facing-east").ToUpperInvariant( ) );
271- break;
272-
273- case RotationModes.West:
274- DrawTextGlyph(cr, x, y, width, height, color,Lang.GetMatching("facing-west").ToUpperInvariant( ) );
275- break;
276-
277- case RotationModes.South:
278- DrawTextGlyph(cr, x, y, width, height, color, Lang.GetMatching("facing-south").ToUpperInvariant( ) );
279- break;
280-
281- default:
282- throw new ArgumentOutOfRangeException( );
283- }
284-
252+ DrawTextGlyph(cr, x, y, width, height, color, rotateMode );
285253 }
286254
287255 public override int GetToolMode(ItemSlot slot, IPlayer byPlayer, BlockSelection blockSelection)
@@ -539,7 +507,7 @@ namespace Adjustor
539507 /// <param name="blockSel">Block sel.</param>
540508 /// <param name="byEntity">By entity.</param>
541509 /// <param name="thePlayer">The player.</param>
542- private void FreeRotation(BlockSelection blockSel, EntityAgent byEntity, IPlayer thePlayer, Block thatBlock, BlockPos position)
510+ private bool FreeRotation(BlockSelection blockSel, EntityAgent byEntity, IPlayer thePlayer, Block thatBlock, BlockPos position)
543511 {
544512 bool rotateHorizontal = false;
545513 AssetLocation renamedAsset = null;
@@ -587,6 +555,7 @@ namespace Adjustor
587555 var rotatedBlock = ServerApi.World.GetBlock(renamedAsset);
588556 if (rotatedBlock != null) {
589557 ServerApi.World.BlockAccessor.ExchangeBlock(rotatedBlock.BlockId, position);
558+ return true;
590559 } else {
591560 Logger.VerboseDebug("{0} CAN'T EXCHANGE {1}", thatBlock.Code, renamedAsset);
592561 }
@@ -623,13 +592,14 @@ namespace Adjustor
623592 var rotatedBlock = ServerApi.World.GetBlock(renamedAsset);
624593 if (rotatedBlock != null) {
625594 ServerApi.World.BlockAccessor.ExchangeBlock(rotatedBlock.BlockId, position);
595+ return true;
626596 } else {
627597 Logger.VerboseDebug("{0} CAN'T EXCHANGE {1}", thatBlock.Code, renamedAsset);
628598 }
629599 }
630600 }
631601
632-
602+ return false;
633603 }
634604
635605 /// <summary>
@@ -641,7 +611,7 @@ namespace Adjustor
641611 /// <param name="thePlayer">The player.</param>
642612 /// <param name="thatBlock">That block.</param>
643613 /// <param name="position">Position.</param>
644- private void FixedRotation(RotationModes rotationMode, BlockSelection blockSel, EntityAgent byEntity, IPlayer thePlayer, Block thatBlock, BlockPos position)
614+ private bool FixedRotation(RotationModes rotationMode, BlockSelection blockSel, EntityAgent byEntity, IPlayer thePlayer, Block thatBlock, BlockPos position)
645615 {
646616 AssetLocation renamedAsset = RenameBlockFace(thatBlock, rotationMode);
647617
@@ -655,6 +625,7 @@ namespace Adjustor
655625 var rotatedBlock = ServerApi.World.GetBlock(renamedAsset);
656626 if (rotatedBlock != null) {
657627 ServerApi.World.BlockAccessor.ExchangeBlock(rotatedBlock.BlockId, position);
628+ return true;
658629 } else {
659630 Logger.VerboseDebug("{0} CAN'T EXCHANGE {1}", thatBlock.Code, renamedAsset);
660631 }
@@ -664,6 +635,8 @@ namespace Adjustor
664635 #endif
665636 }
666637 }
638+
639+ return false;
667640 }
668641
669642 private AssetLocation RenameBlockFace(Block thatBlock, RotationModes rotationMode)
@@ -731,23 +704,97 @@ namespace Adjustor
731704 return new Color(r: ColorUtil.ToRGBADoubles(color)[0], g: ColorUtil.ToRGBADoubles(color)[1], b: ColorUtil.ToRGBADoubles(color)[2], a: ColorUtil.ToRGBADoubles(color)[3]);
732705 }
733706
734- private void DrawTextGlyph(Context cr, int x, int y, int width, int height, int color, string text)
707+ private void DrawTextGlyph(Context cr, int x, int y, int width, int height, int color, RotationModes toolMode)
735708 {
709+ string text = string.Empty;
736710 TextDrawUtil stampy = new TextDrawUtil( );
737711
738712 Pattern pattern = null;
739713 Matrix matrix = cr.Matrix;
740714
741715 cr.Save( );
716+
717+ ElementBounds bounds = ElementBounds.Fixed(width, height);
718+
742719 /*
743- float local_width = 220;
744- float local_height = 182;
745- float scale = Math.Min(width / local_width, height / local_height);
746- matrix.Translate(x + Math.Max(0, (width - local_width * scale) / 2), y + Math.Max(0, (height - local_height * scale) / 2));
747- matrix.Scale(scale, scale);
748- cr.Matrix = matrix;
720+ if (cr.GetTarget( ) is ImageSurface) {
721+ ImageSurface imgSurface = ( ImageSurface )cr.GetTarget( );
722+ bounds = ElementBounds.Fixed(imgSurface.Width, imgSurface.Height);
723+ }
749724 */
750725
726+ CairoFont font = CairoFont.WhiteMediumText( );
727+ font.StrokeColor = ColorUtil.BlackArgbDouble;
728+ font.FontWeight = FontWeight.Bold;
729+
730+ switch (toolMode) {
731+ case RotationModes.Free:
732+ text = Lang.GetMatching("adjustor:rotation-free").ToUpper( );
733+
734+ cr.SetSourceRGB(0D, 0.75D, 0D);
735+ cr.Arc(24, 24, 18, 0, 6D);
736+ cr.Stroke( );
737+
738+ break;
739+
740+ case RotationModes.Up:
741+ text = Lang.GetMatching("adjustor:rotation-up").ToUpper( );
742+
743+ cr.SetSourceRGB(0.85D, 0.85D, 0.85D);
744+ cr.Rectangle(4, 4, 38, 8);
745+ cr.Stroke( );
746+
747+ break;
748+
749+ case RotationModes.Down:
750+ text = Lang.GetMatching("adjustor:rotation-down").ToUpper( );
751+
752+ cr.SetSourceRGB(0.85D, 0.85D, 0.85D);
753+ cr.Rectangle(4, 34, 38, 8);
754+ cr.Stroke( );
755+
756+ break;
757+
758+ case RotationModes.North:
759+ text = Lang.GetMatching("facing-north").ToUpper( );
760+
761+ cr.SetSourceRGB(0.95D, 0D, 0D);
762+ cr.MoveTo(24, 24);
763+ cr.RelLineTo(0, -16);
764+ cr.Stroke( );
765+ break;
766+
767+ case RotationModes.East:
768+ text = Lang.GetMatching("facing-east").ToUpper( );
769+
770+ cr.SetSourceRGB(0.85D, 0.85D, 0.85D);
771+ cr.LineWidth = 1.0D;
772+ cr.MoveTo(24, 24);
773+ cr.RelLineTo(16, 0);
774+ cr.Stroke( );
775+ break;
776+
777+ case RotationModes.West:
778+ text = Lang.GetMatching("facing-west").ToUpper( );
779+
780+ cr.SetSourceRGB(0.85D, 0.85D, 0.85D);
781+ cr.LineWidth = 1.0D;
782+ cr.MoveTo(24, 24);
783+ cr.RelLineTo(-16, 0);
784+ cr.Stroke( );
785+ break;
786+
787+ case RotationModes.South:
788+ text = Lang.GetMatching("facing-south").ToUpper( );
789+
790+ cr.SetSourceRGB(0.85D, 0.85D, 0.85D);
791+ cr.LineWidth = 1.0D;
792+ cr.MoveTo(24, 24);
793+ cr.RelLineTo(0, 16);
794+ cr.Stroke( );
795+ break;
796+ }
797+
751798 cr.Operator = Operator.Over;
752799 pattern = new SolidPattern(ToCarioColor(color));
753800 cr.SetSource(pattern);
@@ -758,17 +805,15 @@ namespace Adjustor
758805 cr.Antialias = Antialias.Default;
759806 cr.FillRule = FillRule.Winding;
760807
761- stampy.DrawTextLine(cr, CairoFont.WhiteMediumText( ).WithFontSize(96F).WithWeight(FontWeight.Bold), text, 8D, 16D);
762- //cr.LineWidth = 3D;
763- //cr.MoveTo(64, 16);
764- //cr.RelLineTo(0D, 248D);
808+ font.AutoFontSize(text, bounds);
809+ font.UnscaledFontsize += 25;
810+
811+ stampy.DrawTextLine(cr, font, text, 4D, height/2);
765812
766813 cr.FillPreserve( );
767814 }
768815
769816
770-
771-
772817 #endregion
773818 }
774819 }
--- a/AdjustorMod/modinfo.json
+++ b/AdjustorMod/modinfo.json
@@ -3,7 +3,7 @@
33 "name": "Adjustment Tool",
44 "description" : "Alter, Rotate blocks without breaking them. Now with Economy tool!",
55 "authors": ["Melchior", ],
6- "version": "0.1.7",
6+ "version": "0.1.8",
77 "dependencies": {
88 "game": "1.9.6",
99 "survival": ""